JSFiddle - React, Tailwind, and code Playground

by infous

JavaScript

const abortController = new AbortController();
// fire the request, with an abort signal,
// which will permit premature abortion
fetch(`https://api.coinbase.com/v2/prices/spot?currency=USD&a=1`, {
  signal: abortController.signal,
});
fetch(`https://api.coinbase.com/v2/prices/spot?currency=USD&a=2`, {
  signal: abortController.signal,
});
fetch(`https://api.coinbase.com/v2/prices/spot?currency=USD&a=3`);

// abort the request in-flight
// the request will be marked as "cancelled" in devtools
abortController.abort();