Здравствуйте, я получаю эту ошибку с почтальоном и мерном.
Это моя ошибка:
TypeError: Cannot destructure property 'name' of 'req.body' as it is undefined.<br> at C:\AppsProjects\MERN\InstagramClone\server\routes\auth.js:10:12<br> at Layer.handle [as handle_request] (C:\SAppsProjects\MERN\InstagramClone\server\node_modules\express\lib\router\layer.js:95:5)<br> at next (C:\AppsProjects\MERN\InstagramClone\server\node_modules\express\lib\router\route.js:137:13)<br> at Route.dispatch (C:\SusmitAppsProjects\MERN\InstagramClone\server\node_modules\express\lib\router\route.js:112:3)<br> at Layer.handle [as handle_request] (C:\AppsProjects\MERN\InstagramClone\server\node_modules\express\lib\router\layer.js:95:5)<br> at C:\Projects\MERN\InstagramClone\server\node_modules\express\lib\router\index.js:281:22<br> at Function.process_params (C:\Projects\MERN\InstagramClone\server\node_modules\express\lib\router\index.js:335:12)<br> at next (C:\SusmitAppsProjects\MERN\InstagramClone\server\node_modules\express\lib\router\index.js:275:10)<br> at Function.handle (C:\AppsProjects\MERN\InstagramClone\server\node_modules\express\lib\router\index.js:174:3)<br> at router (C:\AppsProjects\MERN\InstagramClone\server\node_modules\express\lib\router\index.js:47:12)<br> at Layer.handle [as handle_request] (C:\AppsProjects\MERN\InstagramClone\server\node_modules\express\lib\router\layer.js:95:5)<br> at trim_prefix (C:\tAppsProjects\MERN\InstagramClone\server\node_modules\express\lib\router\index.js:317:13)<br> at C:\AppsProjects\MERN\InstagramClone\server\node_modules\express\lib\router\index.js:284:7<br> at Function.process_params (C:\AppsProjects\MERN\InstagramClone\server\node_modules\express\lib\router\index.js:335:12)<br> at next (C:\AppsProjects\MERN\InstagramClone\server\node_modules\express\lib\router\index.js:275:10)<br> at expressInit (C:\AppsProjects\MERN\InstagramClone\server\node_modules\express\lib\middleware\init.js:40:5)
Это мой код в аутентификации. js:
const express = require('express')
const router = express.Router()
router.get('/',(req,res)=>{
res.send("hello")
})
router.post('/signup',(req,res)=>{
const {name,email,password} = req.body
if(!email || !password || !name){
res.json({error:"please add all the fields"})
}
res.status.json({message:"successfuly posted"})
})
module.exports = router
Это то, что я поместил в Postman:
{
"name":"BIdev",
"email":"vnnfvji@rvfij.com",
"password":"123ramesh"
}