HTTP Methods for Web Development

HTTP methods used for client-server Communication. Using the HTTP methods, we can easily handle any type of request. Using this, we can fetch Data from the Server or we can send the data to the Server.

HTTP methods are also known as HTTP Verb.

  • GET: This method is used to get data from the server without modifying it.
    • Example: https://www.example.net/api/employee/1
    • Retrieves the Employee with ID 1
      Carbon
  • POST: This method is used to submit data to the server and create new resources.
    • Example: https://www.example.net/api/employee/create
    • When a user submits a post request to the server. it will create new employee records with submitted data.
      Submitted data
  • PUT: This method is used to update data submitted to the server.
    • Example: https://www.example.net/api/employee/update/1
    • When the user submits the PUT request to the server. it will update the employee with ID 1
      PUT request
  • DELETE: This method is used to delete the data from the database server.
    • Example: https://www.example.net/api/employee/delete/1
    • When the user submits the DELETE request to the server. it will delete employees with ID 1
      DELETE request
  • PATCH: This method applies partial updates to a resource on a server.
    • Example: https://www.example.net/api/employee/update/id
    • When the user submits the PATCH request to the server. it will partially updates submitted data(like email/name update) of employee with id 1
      PATCH request
  • HEAD: This method is used to get data from the server without modifying it.
    • Example: https://www.example.net/api/employee/1
    • When the user submits the HEAD request to the server. it retrieves the HTTP headers of a resource without the body.
      HEAD request
  • OPTION: This method is used to retrieve information about the supported HTTP methods and headers for a resource.
    • Example: https://www.example.net/api/employee
    • When a user submits the OPTIONS request to the server .browser, it checks whether this endpoint supports the http method type or not. For example, when the user hits the create endpoint at that time, the browser checks create method supports HTTP POST or not.
      HTTP POST

Sample code is available in my GitHub repository. Please check out my GitHub repository source code. If you enjoyed this article, please follow me on LinkedIn https://www.linkedin.com/in/mohitkalajain/ and like it. Thank you for your support.


Similar Articles