I am sending some data from the front end to the back end. I am trying to send data as an object to the back. When it arrives, it is obviously req.body.data, but should land in the backend as req.body. How do I destructure the request, either from the front or the back so that the back only receives req.body
front end
const { user } = await axios.post('http://localhost:3000/auth/signup', {data});
Backend (what I want)
if(req.body.type === 'vendor') {
Right now the backend received (What i dont want)
if(req.body.data.type....)
>Solution :
Your passing data as an object prop. Just pass it directly:
const { user } = await axios.post('http://localhost:3000/auth/signup', data)