In this article, we are going to learn the most common HTTP methods(POST, GET, PUT, PATCH, DELETE). If you are a beginner then you are confused when using those HTTP methods. Let’s try to clear your confusion through the examples.
We will be using this fake API for a demonstration. with credits to https://jsonplaceholder.typicode.com/
The most commonly used HTTP methods POST, GET, PUT, PATCH, DELETE are similar to CURD (create, update, read, delete) operations in the database. Just try to remember below the key Points
Get method is used to retrieve or get the information from the given server using a given URL. In REST CURD, it performs the read operation.
_Let’s try GET method _:
Let’s set up an HTML file that you can run locally on your browser. Create a file called get.html.Let’s look at the code :
Get method Code
get method output
Post is used for sending data to the server such as uploading a file or transferring some data or adding a new row to the back end table to any kind of web form. In a simple sentence, we can say that the post method is used for inserting new items in the backend server. In REST CRUD operation it performs the create operation.
#get-method #javascript-fetch-api #http-methods #restful-api