Skip to content

Instantly share code, notes, and snippets.

@EmperorEarth
Last active March 8, 2017 02:29
Show Gist options
  • Save EmperorEarth/4c26b17f26333e9f1cbf5f8e5f03d16b to your computer and use it in GitHub Desktop.
Save EmperorEarth/4c26b17f26333e9f1cbf5f8e5f03d16b to your computer and use it in GitHub Desktop.
fetch(url, {opts})
.then(response => response.headers.get(`Authorization`))
fetch(url, {opts})
.then(response => response.json())
// {}.data is a promise, not the parsed json
fetch(url, {opts})
.then(response => {
return {
authToken: response.headers.get(`Authorization`),
data: response.json(),
}
}
// response is already consumed and parsed, response.headers is now undefined
fetch(url, {opts})
.then(response => response.json())
.then(response => {
return {
authToken: response.headers.get(`Authorization`),
data: response,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment