We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 026b4a9 commit f9eb0faCopy full SHA for f9eb0fa
01-first-async-await-function.js
@@ -1,13 +1,11 @@
1
const fetch = require('node-fetch');
2
3
-function getZhihuColumn(id) {
+async function getZhihuColumn(id) {
4
const url = `https://zhuanlan.zhihu.com/api/columns/${id}`;
5
- fetch(url)
6
- .then(response => response.json())
7
- .then(column => {
8
- console.log(`NAME: ${column.name}`);
9
- console.log(`INTRO: ${column.intro}`);
10
- });
+ const response = await fetch(url);
+ const column = await response.json();
+ console.log(`NAME: ${column.name}`);
+ console.log(`INTRO: ${column.intro}`);
11
}
12
13
getZhihuColumn('feweekly');
0 commit comments