DEV Community

woongnguyen
woongnguyen

Posted on

POSTMAN can't get request body object

hi all i have issue when i tried to post new data to MongoDB via postman. I use POST methor to push data, there is my code methor:
postman display ===>
POST http://localhost:3000/users/
{
"name": "Ngoc Tram",
"email": "tramltn24@example.com",
"password": "Red123545!"
}

index display ===>

app.post('/users', async (req, res) => {
const addUser = new User(req.body)
console.log(req.body)
try {
await addUser.save()
res.status(201).send(addUser)
} catch (e) {
res.status(400).send(e)
}
})


and here is my terminal result ==>

[nodemon] restarting due to changes...
[nodemon] starting node src/index.js
Server is up on port 3000
{}

{}

In addiction, GET methor still working correctly

Top comments (0)