Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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())
        )
    })
 
PREVIOUS NEXT
Tagged: #js #promise #return #json #array
ADD COMMENT
Topic
Name
8+3 =