Skip to content

Instantly share code, notes, and snippets.

@simonschwartz
Last active April 7, 2019 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonschwartz/d4a558a1b92286e2632616f89368430a to your computer and use it in GitHub Desktop.
Save simonschwartz/d4a558a1b92286e2632616f89368430a to your computer and use it in GitHub Desktop.
import { createRequest } from 'request-state-wrapper';
const getRepoDetails = () =>
fetch('https://api.github.com/repos/nodejs/node').then(response => response.json());
// Create your request with request-state-wrapper
const request = createRequest({
request: getRepoDetails,
stalledDelay: 1000,
onStalled: () => { /* handle stalled state */ },
});
// Run it!
request()
.then(response => { /* handle request response */ })
.catch(error => { /* handle request error */ });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment