Skip to content
Advertisement

Tag: promise

Javascript: how to create an infinite-loop of promises?

I want to write in Javascript the following pseudo-code: I’ll explain it in words: asyncOperation uses a Promise, for example an AJAX call. I want that if the promise is rejected, then asyncOperation will be invoked again. Do you know how it can be done in Javascript? Answer If you’re going to use a loop, then you will have to

script ends despite unresolved promise

Consider this: The scripts terminates at the await and the log is never printed to sdout, I don’t understand why Answer Nothing is wrong with your code. That’s just the model of Node. If there is no pending I/O pending promises don’t prevent Node from exiting. You can schedule some I/O if you want to stop Node from exiting but

Node: Using promise.all() to call API’s in parallel?

I’m a bit confused how promise.all work, does it run the array of promises in parallel? So here is a sample code From what I observed, Promise.all runs the promises in parallel, and wait for all promises to finish. Answer does it run the array of promises in parallel Promise.all doesn’t, no; your code does (well, probably; see the Notes

How to alter a API response with Javascript

I wrote this little app that takes in a set of starwars characters and returns images in an array. The result of the above code looks like this : But i would like a result where i can know which image belongs to which keyword. Maybe a format like this or something similar : I tried this : Results were

How do I make multiple fetch calls without getting 429 error?

I came across a problem in a book which I can’t seem to figure out. Unfortunately, I don’t have a live link for it, so if anyone could help me with my approach to this theoretically, I’d really appreciate it. The process: I get from a fetch call an array of string codes ([“abcde”, “fghij”, “klmno”, “pqrst”]). I want to

Advertisement