📜  js 承诺全部返回 json 数组 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:04.645000             🧑  作者: Mango

代码示例1
const requests = ['myapi.com/list','myapi.com/trending']
const jsonArray = await Promise.all(requests.map(url => fetch(url)))
    .then(async (res) => {
        return Promise.all(
            res.map(async (data) => await data.json())
        )
    })