There are 9 HTTP request methods:
❯ GET
❯ PUT
❯ POST
❯ HEAD
❯ TRACE
❯ PATCH
❯ DELETE
❯ OPTIONS
❯ CONNECT
Did you know? Let's discuss each of these 🧵👇
HTTP defines a set of request methods.
Each request method indicates a different action.
Sometimes we call them HTTP verbs.
Each of them implements a different logic.
📮 GET
Use the GET method to get data from a server.
The GET method is the most common. You send a GET request when you browse a website.
❯❯ Requests using GET should only retrieve data.
📮 POST
Use the POST method to submit data to the server.
POST requests often cause a state change or have side effects on the server.
❯❯ A standard GraphQL request uses POST requests.
📮 PUT
The PUT method replaces all the current data on the target endpoint with the new data you send as the payload.
📮 PATCH
The PATCH method applies partial modifications to a resource.
❯❯ Remember, PUT changes everything, and PATCH is a partial modification of data on the server.
📮 HEAD
The HEAD method asks for a response identical to a GET request, but without the response body. So yeah, it's small, quick, and saves bandwidth.
📮 DELETE
Use the DELETE method to delete the specified resource. As the name suggests, that's how you DELETE things on your server.
📮 CONNECT
The CONNECT method establishes a tunnel for two-way communication between the client and the server.
📮 OPTIONS
The OPTIONS method describes the communication options for the (target resource) on the server.
Use the OPTIONS request to identify allowed request methods. That's how you know which HTTP method to use on which endpoint.
📮 TRACE
Use the TRACE method to debug a request.
The TRACE method performs a message loop-back test along the path to the target resource. This provides a proper and useful debugging mechanism.
I hope you learn something here. For more threads like this, feel free to follow this guy 🤜 @MrAhmadAwais 🤛
Use your code for good.