Best Practices to Asynchronously Send Information to Two APIs Without Blocking?

18 Replies, 1166 Views

Honestly, async/await is the move here. In JS, you can use `fetch` with async/await to asynchronously send information to two APIs without blocking the main thread. Just wrap them in `Promise.all()` and you’re golden.

For rate limits, I’d recommend using a library like `p-limit` to control concurrency. And for retries, `p-retry` is super handy.

One thing to watch out for: make sure you’re handling timeouts properly. Nothing worse than a request hanging forever and freezing your app.

Messages In This Thread



Users browsing this thread: 1 Guest(s)