HTTP Methods Explained

The difference between the various existing HTTP methods.

Many people have this doubt because when developing a REST API, as you choose different routes, you have to decide which HTTP method or verb to use.

When developing a REST API, basically you create a web service that relies on the HTTP protocol, which has many specific methods to send or receive information.

The most common methods and their differences are the following:

#1 GET method:

It is used to retrieve resources from the API, backend, or server. So the most common use of this method is when we type a URL in our browser and load it. That is making us retrieve data using the GET method.

Basically, when we browse a website with our browser, we are making a request to fetch data via GET.

Likewise, we can make an AJAX request with GET or request info from the backend with GET. The HTTP GET method is responsible for fetching data from the backend, API, web service, or whatever is using HTTP, obviously.

#2 POST method

It helps us save resources in our backend. Its most common use is, for example, when there is a form on a website, POST is usually used because the info is hidden in the headers and thus hidden from the URL. So the information travels more “securely”.

This method is responsible for saving information in our API or backend through an HTTP request you make to store resources in the backend, whether it is a photo, text, new user, image, etc., etc.

#3 PUT method

It helps us update resources in our backend. Edit users or edit some post or database record. Anything that involves updating uses the PUT method.

#4 DELETE method.

It is used to delete things from the server, API, or database.

These are the 4 most popular HTTP methods for frontend or backend development.

Leave a Reply

Your email address will not be published. Required fields are marked *