Skip to content

Instantly share code, notes, and snippets.

@morenoh149
Created September 6, 2018 22:18
Show Gist options
  • Save morenoh149/2820d40ea7aeca3d6a2eb6ad18515d0d to your computer and use it in GitHub Desktop.
Save morenoh149/2820d40ea7aeca3d6a2eb6ad18515d0d to your computer and use it in GitHub Desktop.
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