Full-Stack Web Development with Vue.js and Node

(singke) #1
Introducing REST APIs Chapter 4

if (error) { console.log(error); }
res.send(user)
})
})

In Postman, set the method as POST, the URL as http://localhost:3000/users, set the


parameters to raw JSON, and provide the following input:


{
"name": "Dave",
"email": "[email protected]"
}

Unlike the GET request, we have to pass the name and email of the user we want to add in


the body parameter. Now, if we run a GET all users query, we should be able to see this


new user. If we run the POST request twice with the same parameters, then it creates two


different resources.

Free download pdf