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

@ -30,7 +30,7 @@ let animal = new Animal("My animal");
...And `Rabbit`: ...And `Rabbit`:
```js ```js
class Rabbit extends Animal { class Rabbit {
constructor(name) { constructor(name) {
this.name = name; this.name = name;
} }

View file

@ -273,7 +273,7 @@ The pattern is very common, it's not about users, but just about anything. For i
What we'd like to have is an iterable source of commits, so that we could use it like this: What we'd like to have is an iterable source of commits, so that we could use it like this:
```js ```js
let repo = 'iliakan/javascript-tutorial-en'; // Github repository to get commits from let repo = 'javascript-tutorial/en.javascript.info'; // Github repository to get commits from
for await (let commit of fetchCommits(repo)) { for await (let commit of fetchCommits(repo)) {
// process commit // process commit
@ -320,7 +320,7 @@ An example of use (shows commit authors in console):
let count = 0; let count = 0;
for await (const commit of fetchCommits('iliakan/javascript-tutorial-en')) { for await (const commit of fetchCommits('javascript-tutorial/en.javascript.info')) {
console.log(commit.author.login); console.log(commit.author.login);

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: For instance, here we get a JSON-object with latest commits from Github:
```js run async ```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 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: Or, the same using pure promises syntax:
```js run ```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(response => response.json())
.then(commits => alert(commits[0].author.login)); .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: We can get individual headers or iterate over them:
```js run async ```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 // get one header
alert(response.headers.get('Content-Type')); // application/json; charset=utf-8 alert(response.headers.get('Content-Type')); // application/json; charset=utf-8

View file

@ -39,7 +39,7 @@ Here's the full code to get response and log the progress, more explanations fol
```js run async ```js run async
// Step 1: start the fetch and obtain a reader // Step 1: start the fetch and obtain a reader
let response = await fetch('https://api.github.com/repos/iliakan/javascript-tutorial-en/commits?per_page=100'); let response = await fetch('https://api.github.com/repos/javascript-tutorial/en.javascript.info/commits?per_page=100');
const reader = response.body.getReader(); const reader = response.body.getReader();

View file

@ -14,7 +14,7 @@ We'd also like to collaborate on the tutorial with other people.
Something's wrong? A topic is missing? Explain it to people, add as PR 👏 Something's wrong? A topic is missing? Explain it to people, add as PR 👏
**You can edit the text in any editor.** The tutorial uses enhanced "markdown" format, easy to grasp. And if you want to see how it looks on-site, there's a server to run the tutorial locally at <https://github.com/iliakan/javascript-tutorial-server>. **You can edit the text in any editor.** The tutorial uses enhanced "markdown" format, easy to grasp. And if you want to see how it looks on-site, there's a server to run the tutorial locally at <https://github.com/javascript-tutorial/server>.
The list of contributors is available at <https://javascript.info/about#contributors>. The list of contributors is available at <https://javascript.info/about#contributors>.
@ -36,4 +36,4 @@ It's very easy to add something new.
--- ---
💓 💓
Ilya Kantor Ilya Kantor @iliakan