What is a GET request?

what is a GET request

If you just got started with web development you might have heard GET requests. It might have happened while you worked with a back-end language like PHP or while you were trying to connect to an API.

To put it in simple terms, the HTTP GET request is a way for the HTTP protocol to say that the request being performed is only trying to retrieve some data. This kind of request shouldn’t be used to upload data to a database from a user form or to delete data. There are other HTTP verbs(that’s how they are called) responsible for that.

If you are interested in learning about the different HTTP verbs available, just keep reading.

POST

I was not sure what the difference between a GET and POST request was for quite sometime after learning about them. These names were all just a blur to me but luckily I found out that a POST request is also an HTTP verb but this one specifies to the server that we are submitting some data.

Let’s look at an example. You create a website to store all of you favorite book covers and descriptions. You can specify that all requests should be made to the “/books” method. What the HTTP verbs allow you to do is to choose what you want to do, depending on what kind of request you receive. So if a GET request asks for “/books” then a list of all books is shown, but if a POST request sends data to “/books”, a new book is created.

That is how these verbs can be used. To specify what should happen based on the type of request.

DELETE

As the name says, a DELETE request deletes the record it is pointed at e.g : “books/1” – which means, the book with id 1.

PATCH

This kind of HTTP verb is used to update part of a record. This one can also be confused for the PUT HTTP verb. The difference between the HTTP PUT and HTTP PATCH is that PUT sends a complete record to the back-end and that object replaces whatever was in the specified place, whereas the HTTP PATCH verb only updates part of the record.


Those are the most common HTTP verbs. You might encounter a few others in the wild, like OPTIONS or HEAD but you’ll rarely have to directly work with those.

There we go! That is our short summary on HTTP verbs.

Thanks for reading,

Gásten Sauzande.

Leave a Reply

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