Excuse me if this is pretty obvious! I am having a tough time trying to understand how does node.js respond to requests from browser. I have gone through tutorials on internet where express.js was used to build the rest server side code with node.js. Now apart from that routes are set up which works on promises. So it is pretty obvious that the response would be sent back only when the promises resolve. So the flow would be - browser -> REST Service REST Service -> find the route -> hit the service -> get the data -> Send the data back to the browser
( If you want to understand the example more, you can look at the following link - https://www.codementor.io/olatundegaruba/nodejs-restful-apis-in-10-minutes-q0sgsfhbd )
The entire process on second line is in asynchronous mode. So will there be a thread hanging at the server end and browser would be waiting for node.js enabled REST service to return response ? If that is not the case, how does the browser or say a REST client such as POSTMAN come to know of the response in real time.
via user3276247
No comments:
Post a Comment