fetch multiple urls javascript

Solutions on MaxInterview for fetch multiple urls javascript by the best coders in the world

showing results for - "fetch multiple urls javascript"
Sam
18 Mar 2016
1async function getAllUrls(urls) {
2    try {
3        var data = await Promise.all(
4            urls.map(
5                url =>
6                    fetch(url).then(
7                        (response) => response.json()
8                    )));
9
10        return (data)
11
12    } catch (error) {
13        console.log(error)
14
15        throw (error)
16    }
17}
18