Monday 23 July 2018

Writing all my code as sync.

Hi, I am kind of new of node (I have been learning it for 1.5 months). What I usually do is write all my code as if it was sync. For example i have a get request in which i have to first retrieve some data from my DB before sending a response. What i would do is:getFromDB().then(function(){ getFromDB().then(function(){ getFromDB().then() //etc. }) }) Basically all of the actions i perform before sending a request are connected by then(). I don't know if this is bad however i think that it might block the code a bit.What are your suggestions?Thanks in advance :)

Submitted July 23, 2018 at 08:09AM by everek123

No comments:

Post a Comment