Friday 13 October 2017

New to node, need help with query timing

Long time Coldfusion developer, working on porting our legacy apps over to NodeJS.Im working on a work source provider for my firm, I query their API and pull down the XML, convert this to JSON using xml2js then proceed to parse the content ready to insert into our database for the end users to carry out the work.My trouble is I have 3 functions, one creates a place holder in the table, the next loops through the client list and adds these to the record based on the ID, then the final insert is for the rest of the content.The trouble I am having is with the asynchronous nature of node. Its that fast that the other functions try to complete before the previous functions have finished.How can I solve the timing of these queries to wait for the others to complete? Would I use promises?Here are my functions: http://ift.tt/2gB8755 would greatly appreciate any help or guidance on this.

Submitted October 13, 2017 at 09:32AM by mattj85

No comments:

Post a Comment