I’m working on a project involving nodejs and I’m having a problem with a request body that is undefined
On the client side I fetch some data
I also get the following error telling me the property is undefined or null
TypeError: Cannot destructure property
Anyone know what might cause this and how I can fix this, all help is greatly appreciated.
2
Answers
here ‘s fixing
};
});
this is back-end code too
Convert
body: JSON.stringify(userData),
tobody: userData
Add
app.use(express.json()
aboveapp.post
so you can work with the json. req.body should have an email property on the server when fetching now. Your function signup takes 2 arguments, (req, res) instead of (req.body) BTW.