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 ca5c5a7 commit b7652eaCopy full SHA for b7652ea
08-await-in-loops.js
@@ -0,0 +1,25 @@
1
+const fetch = require('node-fetch');
2
+const bluebird = require('bluebird');
3
+
4
+async function getZhihuColumn(id) {
5
+ await bluebird.delay(1000);
6
+ const url = `https://zhuanlan.zhihu.com/api/columns/${id}`;
7
+ const response = await fetch(url);
8
+ return await response.json();
9
+}
10
11
+const showColumnInfo = async () => {
12
+ console.time('showColumnInfo');
13
14
+ const names = ['feweekly', 'toolingtips'];
15
+ const promises = names.map(x => getZhihuColumn(x));
16
+ for (const promise of promises) {
17
+ const column = await promise;
18
+ console.log(`Name: ${column.name}`);
19
+ console.log(`Intro: ${column.intro}`);
20
+ }
21
22
+ console.timeEnd('showColumnInfo');
23
+};
24
25
+showColumnInfo();
0 commit comments