Skip to content

Instantly share code, notes, and snippets.

@bartcis
Created January 20, 2020 20:06
Show Gist options
  • Save bartcis/a35a628ad4da270ad753bc006d99eb1d to your computer and use it in GitHub Desktop.
Save bartcis/a35a628ad4da270ad753bc006d99eb1d to your computer and use it in GitHub Desktop.
Function to fetch and update abort functions
const fetchOnClick = async () => {
try {
abortFuncs.current.unshift(abortArticleRequest);
const newArticleRequest = await articleRequest;
const newArticle = await newArticleRequest.json();
setState([...state, newArticle]);
setArticleId(articleId +1);
} catch(e) {
console.error(e);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment