Skip to content

Commit 01bdbf0

Browse files
Merge pull request #268 from Userbit/master
Some corrections in **Concurrency** section
2 parents d31c5fb + 0f5326f commit 01bdbf0

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1908,11 +1908,11 @@ import { writeFile } from "fs";
19081908

19091909
get(
19101910
"https://en.wikipedia.org/wiki/Robert_Cecil_Martin",
1911-
(requestErr, response) => {
1911+
(requestErr, response, body) => {
19121912
if (requestErr) {
19131913
console.error(requestErr);
19141914
} else {
1915-
writeFile("article.html", response.body, writeErr => {
1915+
writeFile("article.html", body, writeErr => {
19161916
if (writeErr) {
19171917
console.error(writeErr);
19181918
} else {
@@ -1927,12 +1927,12 @@ get(
19271927
**Good:**
19281928

19291929
```javascript
1930-
import { get } from "request";
1931-
import { writeFile } from "fs";
1930+
import { get } from "request-promise";
1931+
import { writeFile } from "fs-extra";
19321932

19331933
get("https://en.wikipedia.org/wiki/Robert_Cecil_Martin")
1934-
.then(response => {
1935-
return writeFile("article.html", response);
1934+
.then(body => {
1935+
return writeFile("article.html", body);
19361936
})
19371937
.then(() => {
19381938
console.log("File written");
@@ -1956,11 +1956,11 @@ today!
19561956

19571957
```javascript
19581958
import { get } from "request-promise";
1959-
import { writeFile } from "fs-promise";
1959+
import { writeFile } from "fs-extra";
19601960

19611961
get("https://en.wikipedia.org/wiki/Robert_Cecil_Martin")
1962-
.then(response => {
1963-
return writeFile("article.html", response);
1962+
.then(body => {
1963+
return writeFile("article.html", body);
19641964
})
19651965
.then(() => {
19661966
console.log("File written");
@@ -1974,19 +1974,21 @@ get("https://en.wikipedia.org/wiki/Robert_Cecil_Martin")
19741974

19751975
```javascript
19761976
import { get } from "request-promise";
1977-
import { writeFile } from "fs-promise";
1977+
import { writeFile } from "fs-extra";
19781978

19791979
async function getCleanCodeArticle() {
19801980
try {
1981-
const response = await get(
1981+
const body = await get(
19821982
"https://en.wikipedia.org/wiki/Robert_Cecil_Martin"
19831983
);
1984-
await writeFile("article.html", response);
1984+
await writeFile("article.html", body);
19851985
console.log("File written");
19861986
} catch (err) {
19871987
console.error(err);
19881988
}
19891989
}
1990+
1991+
getCleanCodeArticle()
19901992
```
19911993

19921994
**[⬆ back to top](#table-of-contents)**

0 commit comments

Comments
 (0)