28 lines
679 B
HTML
28 lines
679 B
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<body>
|
|
|
|
<script>
|
|
|
|
// if any of URLs fails, other results are ignored
|
|
// change that:
|
|
// make errors appear as members of the responses array, together with normal results
|
|
|
|
let urls = [
|
|
'https://api.github.com/users/iliakan',
|
|
'https://api.github.com/users/remy',
|
|
'http://no-such-url'
|
|
];
|
|
|
|
// Fix me:
|
|
Promise.all(urls.map(url => fetch(url)))
|
|
// Demo output (no need to change):
|
|
.then(responses => {
|
|
alert(responses[0].status); // 200
|
|
alert(responses[1].status); // 200
|
|
alert(responses[2]); // TypeError: failed to fetch (text may vary)
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|