I am pretty new to Nodejs and come from Java background. I apologize for the long question. I am working on an standalone Nodejs application which has to do steps sequentially. Below are the steps:
Step1: The application has to call the external-server-A or else retry
Step2: Once the above call is success, it has to call external-server-b by taking the response on Step1 or else retry.
Step3: Once the above call is success, it has to invoke local module by taking the response-of-step2 and call a function.
Not to combine all the steps in 1 JS page, I would like to write the functions related to above steps in different JS-pages and import them via require(). I am not sure how to call them sequentially.
Should I have the require(./step2)
, require(./step3)
in the call-back code-block of step1 function and step2 functions.
Thanks in advance for the help.