HTTP Methods for RESTful Services with Examples (Mongoose)

October 9, 2017 superadmin 0

The primary or most-commonly-used HTTP verbs (or methods, as they are properly called) are POST, GET, PUT, PATCH, and DELETE. These correspond to create, read, update, and delete (or CRUD) operations, respectively. POST – Create This is how we can create new items in the database. This will commonly be from an HTTP POST request, although you can do this anywhere you want var article = new Article(req.body); article.save((err, article) => { if (err) { res.status(500).send(err); } res.status(200).send(article); }); GET – Read Here the example like, how HTTP get method are typically used in a RESTful API: 1. Finds all [...]