Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
175 views
in Technique[技术] by (71.8m points)

node.js - can you identify where i am going wrong

this is my code code and i am trying to update things in raw materials

exports.updateRawmateial = (req, res) => {
    const rawmaterial = req.rawmaterial;
    rawmaterial.name = req.body.name;

    rawmaterial.save((err, updatedRawmaterial) => {
        if (err) {
            return res.status(400).json({
                error: "Unable to Upadte the RawMaterial"
            });
        }
        res.json(updatedRawmaterial);
    });
};

and this is the error I am getting

Cannot set property 'name' of undefined
    at exports.updateRawmateial (C:UserslmtlaOneDriveDesktoppraveenbhaiackendcontrollers
awmaterial.js:45:22)
    at Layer.handle [as handle_request] (C:UserslmtlaOneDriveDesktoppraveenbhaiackend
ode_modulesexpresslib
outerlayer.js:95:5)
question from:https://stackoverflow.com/questions/66060453/can-you-identify-where-i-am-going-wrong

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...