Web Dev Everyday - 17th September 2024🖥️

Daily dose of web dev

Welcome to Web Dev Everyday – your daily dose of 3 minute web development emails.

Let's dive in!

🎯 Tip of the day

9 HTTP Request methods

1. GET

  • Purpose: Retrieves data from a server without modifying it.

  • Example: GET /api/products - Returns all product data.

  • Use Case: When you need to fetch data, like displaying a product list or details.

2. POST

  • Purpose: Sends data to the server to create a new resource.

  • Example: POST /api/orders - Creates a new order.

  • Use Case: When you want to submit new data to the server, such as placing a new order.

3. PUT

  • Purpose: Updates an existing resource entirely.

  • Example: PUT /api/orders/789 - Updates order data with ID 789.

  • Use Case: When you need to update the entire order information, such as modifying order details.

4. PATCH

  • Purpose: Updates part of an existing resource (partial updates).

  • Example: PATCH /api/users/567 { "email": "[email protected]" } - Updates the email for user 567.

  • Use Case: When you want to change specific fields, such as updating a user’s email address.

5. DELETE

  • Purpose: Deletes a resource.

  • Example: DELETE /api/products/345 - Deletes the product with ID 345.

  • Use Case: When you need to remove a resource, like deleting a product or user.

Okay that was easy? Let’s go with rare ones.

6. HEAD

  • Purpose: Similar to GET, but only returns the headers and no body.

  • Example: HEAD /api/orders - Checks if the orders resource exists without returning order data.

  • Use Case: To check the existence of a resource or retrieve metadata without the full data load.

7. OPTIONS

  • Purpose: Describes the communication options for a given URL.

  • Example: OPTIONS /api/users - Returns the permitted HTTP methods for the users resource.

  • Use Case: To discover the supported HTTP methods for interacting with a specific resource.

8. TRACE

  • Purpose: Used for diagnostic purposes; echoes back the received request.

  • Example: TRACE /api/login - Returns the exact login request that the client sent.

  • Use Case: For debugging, allowing clients to see if there are any changes made to their request during transmission.

9. CONNECT

  • Purpose: Establishes a tunnel for communication between the client and the server.

  • Example: CONNECT api.example.com:443 HTTP/1.1 - Connects to the specified URL via HTTPS.

  • Use Case: Typically used to establish secure connections, like tunneling HTTPS requests.

Subscribe to keep reading

This content is free, but you must be subscribed to Web Dev Everyday to continue reading.

Already a subscriber?Sign In.Not now