I’m trying to use fastify and request modules to make an REST API endpoint that returns the combined results from multiple HTTP requests. I can do one HTTP request, but because of the asynchronous nature, I can’t do more than one. Can anyone help with this?
You can try using node-fetch and Promise.all
you can start multiple asynchronous requests. if you’re doing it the callback way, you’ll need some extra logic to run some code after all the requests are done.
if you’re using promises, the above promise.all idea could work. or allSettled if you don’t want to throw away errors
1 Like