Promise.all 里面接受数组,用es6的扩展运算符,来展开 feweekly和toolingtips

    1. const fetch = require("node-fetch")
    2. async function getZhihuColumn(id) {
    3. const url = `https://zhuanlan.zhihu.com/api/columns/${id}`
    4. const response = await fetch(url)
    5. return await response.json()
    6. }
    7. const showCloumnInfo = async () => {
    8. const [ feweekly, toolingtips ] = await Promise.all([
    9. getZhihuColumn("feweekly"),
    10. getZhihuColumn("toolingtips")
    11. ]);
    12. console.log(`标题:${feweekly.title}`)
    13. console.log(`简介:${feweekly.intro}`)
    14. console.log(`标题:${toolingtips.title}`)
    15. console.log(`简介:${toolingtips.intro}`)
    16. };
    17. showCloumnInfo()