Created
September 6, 2018 22:18
-
-
Save morenoh149/2820d40ea7aeca3d6a2eb6ad18515d0d 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
const getInvite = fetch( | |
`${apiHost}/invite/?event=${event_id}&user=${userId}` | |
); | |
const getHost = fetch(`${apiHost}/user/${event.fields.host}/`); | |
Promise.all([getInvite, getHost, delayPromise(1000)()]) | |
.then(values => { | |
values.pop(); // drop delayPromise's return value (undefined) | |
return values.map(v => v.json()); | |
}) | |
.then(responses => { | |
inviteResponse = responses[0]; | |
invite = inviteResponse[0]; | |
hostResponse = responses[1]; | |
host = hostResponse[0]; | |
this.setState({ fetching: false, host, invite }); | |
}) | |
.catch(error => console.error(error)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment