Skip to content

Commit

Permalink
Merge pull request ryanmcdermott#268 from Userbit/master
Browse files Browse the repository at this point in the history
Some corrections in **Concurrency** section
  • Loading branch information
ryanmcdermott authored Oct 29, 2019
2 parents d31c5fb + 0f5326f commit 01bdbf0
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1908,11 +1908,11 @@ import { writeFile } from "fs";
get(
"https://en.wikipedia.org/wiki/Robert_Cecil_Martin",
(requestErr, response) => {
(requestErr, response, body) => {
if (requestErr) {
console.error(requestErr);
} else {
writeFile("article.html", response.body, writeErr => {
writeFile("article.html", body, writeErr => {
if (writeErr) {
console.error(writeErr);
} else {
Expand All @@ -1927,12 +1927,12 @@ get(
**Good:**

```javascript
import { get } from "request";
import { writeFile } from "fs";
import { get } from "request-promise";
import { writeFile } from "fs-extra";
get("https://en.wikipedia.org/wiki/Robert_Cecil_Martin")
.then(response => {
return writeFile("article.html", response);
.then(body => {
return writeFile("article.html", body);
})
.then(() => {
console.log("File written");
Expand All @@ -1956,11 +1956,11 @@ today!
```javascript
import { get } from "request-promise";
import { writeFile } from "fs-promise";
import { writeFile } from "fs-extra";

get("https://en.wikipedia.org/wiki/Robert_Cecil_Martin")
.then(response => {
return writeFile("article.html", response);
.then(body => {
return writeFile("article.html", body);
})
.then(() => {
console.log("File written");
Expand All @@ -1974,19 +1974,21 @@ get("https://en.wikipedia.org/wiki/Robert_Cecil_Martin")
```javascript
import { get } from "request-promise";
import { writeFile } from "fs-promise";
import { writeFile } from "fs-extra";

async function getCleanCodeArticle() {
try {
const response = await get(
const body = await get(
"https://en.wikipedia.org/wiki/Robert_Cecil_Martin"
);
await writeFile("article.html", response);
await writeFile("article.html", body);
console.log("File written");
} catch (err) {
console.error(err);
}
}

getCleanCodeArticle()
```
**[⬆ back to top](#table-of-contents)**
Expand Down

0 comments on commit 01bdbf0

Please sign in to comment.