This commit is contained in:
Ilya Kantor 2019-04-22 17:52:49 +03:00
parent 585b77dbb9
commit 203b8f9f07
5 changed files with 10 additions and 10 deletions

View file

@ -57,7 +57,7 @@ To get the response body, we need to use an additional method call.
For instance, here we get a JSON-object with latest commits from Github:
```js run async
let response = await fetch('https://api.github.com/repos/iliakan/javascript-tutorial-en/commits');
let response = await fetch('https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits');
*!*
let commits = await response.json(); // read response body and parse as JSON
@ -69,7 +69,7 @@ alert(commits[0].author.login);
Or, the same using pure promises syntax:
```js run
fetch('https://api.github.com/repos/iliakan/javascript-tutorial-en/commits')
fetch('https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits')
.then(response => response.json())
.then(commits => alert(commits[0].author.login));
```
@ -119,7 +119,7 @@ There's a Map-like headers object in `response.headers`.
We can get individual headers or iterate over them:
```js run async
let response = await fetch('https://api.github.com/repos/iliakan/javascript-tutorial-en/commits');
let response = await fetch('https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits');
// get one header
alert(response.headers.get('Content-Type')); // application/json; charset=utf-8