Excuse me since I am just starting out using JavaScript and Node.I am coming from Python so I kind of understand how to think about code, and even how to write code.I am working on developing a set of requests to an api, where the next request in the set is dependent on the previous value that was retrieved from the api call. For example I am in a dictionary and I can turn a page, or look at items in the page. I only want to start looking at items on the page once I know I have arrived at the correct page. I am finding this sequential logic difficult to achieve using Node since its designed for async (why then did am I using Node? That's the requirements).I have created a really simple for (let i = 0; i < 5; i++){ if (i ==3) { moveToNextItem } else { moveToNextPage } } however I am obviously not getting the final result that I am expecting since these requests are handled in no particular order.What is the best way to solve something like this?I have seen stuff about promises, but no good examples.Any descriptive help would be really appreciated.Again the main thought that I have is each consecutive request is going to be made based on the previous's response.
Submitted June 14, 2019 at 01:21AM by elyfialkoff
No comments:
Post a Comment