We all know that the application makes an API call to get data and display them. so let's see how things work. I will keep it crisp.
- Firstly, your application makes an HTTP request call to the Node server.
- Now, the Node server gets the request function and makes a call to a remote server for the requested service.
- Without waiting for the response message from the remote server, the node immediately returns a response. which indicates the request was sent successfully.
- When Node receives an HTTP response message from the remote server, it calls the call back function that has been defined in the HTTP request function call.
-
This callback function returns an HTTP response message to the calling application,
Ok, now let's see this in a real-time example.
Let's consider you are hungry and order some food, ill leave the choices to you.
- First, you will open the APP to select our choices and place the order. (This is the HTTP request that the application makes to Node JS)
- Now the restaurant receives the order placed and forwards the order to their kitchen.
- The restaurant would send an order accepted message to you, without waiting for the food to be actually prepared. (This is the immediate response node, which indicates the status of the request).
- Finally, when the food preparation is done, a delivery executive will be assigned for the order. (The delivery executive is the call back function that you defined in the HTTP request). This executive reaches out and delivers you food. (This is the HTT response message )
I hope, you got an high-level understanding of node calls are processed.
Thank you for being patient with me for my first post, if any beginner errors. I will improve myself in upcoming posts.
Top comments (2)
Nicely Written Mukilan.
Can't wait to see more insights from you 👏
Great content!