Member-only story
Common HTTP Request Method
HTTP methods that developers should know
If you’re working on anything online, you’ll definitely come across HTTP request methods, whether you realize it or not. These methods are fundamental to web development, making the essential connections between the client and server possible. Let’s take a closer look at these methods, discuss possible weaknesses and talk about the best ways to handle them.
HTTP GET
The GET method is used to obtain a resource from the server. It’s similar to requesting, “Hey, can you please provide me with this information?” Whenever you click on a link or enter a URL in your browser, you are using the GET method.
For instance, consider an API with a /customers
endpoint. A GET request to this endpoint would typically retrieve a list of all the customers. Because of a GET request only shows data without altering any resources, it is regarded as both safe and idempotent in resource representation context.
Example Usage:
fetch('https://api.example.com/customers')
.then(response => response.json())
.then(data => console.log(data));
This is how the values handled by the target server:
GET /api/customers HTTP/1.1
Host: api.example.com