Last active
April 7, 2019 22:31
-
-
Save simonschwartz/c00a61df93ba08c1a74ce43f1e448e6f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createRequest } from 'request-state-wrapper'; | |
const getNodeRepoDetails = () => | |
fetch('https://api.github.com/repos/nodejs/node').then(response => response.json()); | |
const getGoRepoDetails = () => | |
fetch('https://api.github.com/repos/golang/go').then(response => response.json()); | |
const request = createRequest({ | |
request: [getNodeRepoDetails, getGoRepoDetails], | |
stalledDelay: 1000, | |
onStalled: () => { /* handle stalled state */ }, | |
}); | |
// Run it! | |
request() | |
.then(response => { | |
const [ nodeResponse, goResponse ] = 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