This is my code in userController.js
const registerUser = asyncHandler(async (req, res) => {
const {name, email, password, phoneNumber} = req.body
if(!name || !email || !password || !phoneNumber) {
res.status(400)
throw new Error('Please add all fields')
}
res.json({ message: 'Register user'})
})
CodePudding user response:
You're passing in query params in Postman, but in the controller you are accessing the body.
Change one or the other, either by passing in form data in the body of Postman, or by accessing req.params
in your controller.
CodePudding user response: