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

  1. Create NEW record =>POST
  2. read=>GET
  3. If the record exists then update else create a new record=>PUT
  4. update/modify=>PATCH
  5. delete=>DELETE

The Get Method

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 :

Image for post

Image for post

Get method Code

Image for post

Image for post

get method output

The Post Method

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

HTTP REQUEST Methods-GET, POST, PUT, PATCH, DELETE.
2.90 GEEK