POST Method
The post method is used to send data from the client side to the server side that will be further stored in the database. Suppose in an application, the user registers with their credentials and details to receive those details in the backend through the request body, and storing that data in the database will be achieved under the post method.
Similarly, the post method contains two parameters:the first is the URL, which means the URL for which the method is listening, and the second is the callback function, where that particular callback function takes two default arguments: one is a request made by the client, and the other is a response that will be sent to the client.
The post-request body contains the data sent by the client, and this data can only be accessed after parsing it into JSON.
Syntax:
app.post("URL",(req,res)=>{})
Express JS HTTP Methods
In this article, we are going to learn about the different HTTP methods of Express JS. HTTP methods are hypertext transfer protocol methods to exchange data between two or more layers of an application using a request and response cycle.
In web development, we use HTTP methods to connect client-side code to server-side code and databases. The database for a particular website is too large, so it is not possible to store the database on the client side. That’s why we implement a server and setup different HTTP routes through which we can exchange data from the client side to the server side.
Table of Content
- GET Method
- POST Method
- PUT Method
- DELETE Method