DEV Community

victor-okereke
victor-okereke

Posted on

Introduction to Node Js HTTP

Http is is the primary procedure that dictates the formation of messages or how messages are formatted as they are transmitted across the web. HyperText Transfer Protocol (HTTP) is mainly used for transmitting multimedia documents ,and improve collaborative and distributed features of an application.
Routes are specific URLs to which you make an HTTP Request. If you load a website the web browser sends a request to the web server to get the html that defines the website you are loading. Developed as a client-server protocol, the
application initiates the request and the server is informed about the request. When the web server receives this request, it will send a response: 'ok' and then proceed to serve the html to the browser where it will be rendered. The server decodes the HTTP request and sends it to the corresponding application or server for further processing. Making an http request is basically making a request to your web browser to get a data. This request is called ‘GET’. There are different types of http requests that can be made depending on what the user wants to do: the basic operations that a user may look to perform are to Create a record, Read a record, Update a record or Delete a record.
You can Create a record by making a POST or PUT request. The difference between PUT and POST is that PUT will create a new record (as with POST) if no such record exists, or, it will replace an existing record if the record already exists within that aforementioned data structure. You can Update a record by making a PATCH request. While PUT completely replaces an existing record, PATCH updates something having to do with a specific aspect or property of the record. There is one last fundamental operation and it’s called Delete. As you would expect, the name of such an HTTP Request is “DELETE”, and it works much the same as PATCH, it requires the record to be deleted to be provided in a path or route.
As mentioned before, after making an HTTP Request, we’ll receive a response. Earlier, we said that when your web browser requests to “GET" the HTML from the web server, it’ll respond with “OK”. That is known as an HTTP Status Code, more specifically, HTTP 200 OK.

Top comments (0)