Skip to content

Instantly share code, notes, and snippets.

@jwchang0206
Created March 2, 2020 10:02
Show Gist options
  • Save jwchang0206/939ed634dc392f9ebcf26196508711ad to your computer and use it in GitHub Desktop.
Save jwchang0206/939ed634dc392f9ebcf26196508711ad to your computer and use it in GitHub Desktop.
const controller = new AbortController();
const { signal } = controller;
setTimeout(async () => {
const response = await fetch(url, { signal });
const data = await response.json();
alert(JSON.stringify(data));
}, 5000);
controller.abort();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment