Last active
October 26, 2016 10:39
-
-
Save htsign/4bce3763c86dfe26aa103a5296d85c9b to your computer and use it in GitHub Desktop.
get all response headers and a parsed JSON result with "Fetch API" on ES2015
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 promise = fetch("//api.github.com/users/octocat/orgs"); | |
| promise.then(res => { | |
| const headers = res.headers; | |
| for (let key of headers.keys()) { | |
| console.log(`${key} : ${headers.get(key)}`); | |
| } | |
| return res.json(); // return JSON object, not serialized string | |
| }) | |
| .then(json => console.log(json)); | |
| }).call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment