@@ -1908,11 +1908,11 @@ import { writeFile } from "fs";
1908
1908
1909
1909
get (
1910
1910
" https://en.wikipedia.org/wiki/Robert_Cecil_Martin" ,
1911
- (requestErr , response ) => {
1911
+ (requestErr , response , body ) => {
1912
1912
if (requestErr) {
1913
1913
console .error (requestErr);
1914
1914
} else {
1915
- writeFile (" article.html" , response . body , writeErr => {
1915
+ writeFile (" article.html" , body, writeErr => {
1916
1916
if (writeErr) {
1917
1917
console .error (writeErr);
1918
1918
} else {
@@ -1927,12 +1927,12 @@ get(
1927
1927
** Good:**
1928
1928
1929
1929
``` javascript
1930
- import { get } from " request" ;
1931
- import { writeFile } from " fs" ;
1930
+ import { get } from " request-promise " ;
1931
+ import { writeFile } from " fs-extra " ;
1932
1932
1933
1933
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 );
1936
1936
})
1937
1937
.then (() => {
1938
1938
console .log (" File written" );
@@ -1956,11 +1956,11 @@ today!
1956
1956
1957
1957
``` javascript
1958
1958
import { get } from " request-promise" ;
1959
- import { writeFile } from " fs-promise " ;
1959
+ import { writeFile } from " fs-extra " ;
1960
1960
1961
1961
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 );
1964
1964
})
1965
1965
.then (() => {
1966
1966
console .log (" File written" );
@@ -1974,19 +1974,21 @@ get("https://en.wikipedia.org/wiki/Robert_Cecil_Martin")
1974
1974
1975
1975
``` javascript
1976
1976
import { get } from " request-promise" ;
1977
- import { writeFile } from " fs-promise " ;
1977
+ import { writeFile } from " fs-extra " ;
1978
1978
1979
1979
async function getCleanCodeArticle () {
1980
1980
try {
1981
- const response = await get (
1981
+ const body = await get (
1982
1982
" https://en.wikipedia.org/wiki/Robert_Cecil_Martin"
1983
1983
);
1984
- await writeFile (" article.html" , response );
1984
+ await writeFile (" article.html" , body );
1985
1985
console .log (" File written" );
1986
1986
} catch (err) {
1987
1987
console .error (err);
1988
1988
}
1989
1989
}
1990
+
1991
+ getCleanCodeArticle ()
1990
1992
```
1991
1993
1992
1994
** [ ⬆ back to top] ( #table-of-contents ) **
0 commit comments