HTTP Verbs
HTTP defines a set of request methods to indicate the desired action to be performed for a given resource. Although they can also be nouns, these request methods are sometimes referred to as HTTP verbs. Each of them implements a different semantic, but some common features are shared by a group of them: e.g. a request method can be safe, idempotent, or cacheable.
HTTP verbs are the methods that are used to perform different actions on the server, the most common ones are GET
, POST
, PUT
, PATCH
, DELETE
, and OPTIONS
.
GET
The GET
method is used to retrieve data
from the server, it's the most common method used in the web, and it's used to retrieve data from the server.
POST
The POST
method is used to create new data
on the server.
PUT
The PUT
method is used to full/partial update
data on the server.
PATCH
The PATCH
method is used to partial update
data on the server.
DELETE
The DELETE
method is used to delete data
from the server.
OPTIONS
The OPTIONS method describes the communication options for server, in simple words to know what are the available methods to connect with, usually this is used by the browser not us.
Common usage of HTTP Verbs
The most common one is the GET
method, it's used to retrieve data from the server, any data you might think, this is the default method when you hit a url in your browser, this request is a GET
request.
The POST
method is used to create new data on the server, this is the default method when you submit a form, this request is a POST
request, its best practices when you create some sort of new resources, for example create a new post, register account, but also can be used to update or validate data for example, when submitting login form, its usually a POST
request.
The PUT
method is used to full/partial update data on the server, its best practices when you make minor updates of the resource that you're updating, for example enabling or disabling account, change only name or email.
🎨 Project Repository
You can find the latest updates of this project on Github
😍 Join our community
Join our community on Discord to get help and support (Node Js 2023 Channel).
Top comments (0)