Difference between get and post method
- Nov 13, 2024
- 2 min read
To answer this, first let’s talk about HTTP Request methods. HTTP request methods specify the action that should be taken by the server when processing a client's request. Each HTTP request method serves a specific purpose in client-server communication.
Now, let’s talk about GET method first, I’m sure we all must have browsed through a lot of ecommerce websites, when we search something on the website, the URL looks something like this:
This is the GET method. GET requests are used to retrieve data from a server. When a user submits a GET request, the data is added to the URL in the form of query parameters. These query parameters are visible to anyone who has access to the URL. Although the only limitation is that only fixed length data can be retrieved. These requests are commonly used to fetch content such as web pages, images and other resources.
In the above example of GET URL: ‘q’ is the parameter and its value is keyword.
Now, let’s take an example of you logging into your account. Observe that once you enter the username and password, you get logged in and there is not much change in the URL as well. It’s because the POST method is used to submit data to a server. When a user submits a POST request, the data is sent in the request body rather than in the URL. Since the request is not visible like the URL, it is more secure than the GET method. There is no limitation on the length of data that can be sent. These requests are commonly used to submit form data, upload files, and perform other actions that require the server to take some kind of action. Here is an example of POST method:
username=johnwick&password=secret&remember_me=true
In the above example, there are three parameters: username, password and remember_me, just like it would be in any website while logging in. johnwick is the value for username parameter. Secret is the value for the password parameter.

Comments