Skip to content

Commit ba8cb4f

Browse files
committed
lesson 02: use async function as promise
1 parent f9eb0fa commit ba8cb4f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

02-use-async-function-as-promise.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const fetch = require('node-fetch');
2+
3+
async function getZhihuColumn(id) {
4+
const url = `https://zhuanlan.zhihu.com/api/columns/${id}`;
5+
const response = await fetch(url);
6+
return await response.json();
7+
}
8+
9+
getZhihuColumn('feweekly')
10+
.then(column => {
11+
console.log(`NAME: ${column.name}`);
12+
console.log(`INTRO: ${column.intro}`);
13+
});

0 commit comments

Comments
 (0)