Last active
March 8, 2017 02:29
-
-
Save EmperorEarth/4c26b17f26333e9f1cbf5f8e5f03d16b to your computer and use it in GitHub Desktop.
This file contains 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
fetch(url, {opts}) | |
.then(response => response.headers.get(`Authorization`)) |
This file contains 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
fetch(url, {opts}) | |
.then(response => response.json()) |
This file contains 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
// {}.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