Answers for "js promise all return json array"

1

js promise all return json array

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())
        )
    })
Posted by: Guest on July-04-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language