en.javascript.info/6-async/04-promise-api/01-promise-errors-as-results/solution.view/index.html
Ilya Kantor 455d300d8d renames
2017-05-25 11:56:32 +03:00

24 lines
492 B
HTML

<!DOCTYPE HTML>
<html>
<body>
<script>
let urls = [
'https://api.github.com/users/iliakan',
'https://api.github.com/users/remy',
'http://no-such-url'
];
Promise.all(
urls.map(url => fetch(url).catch(err => err))
)
.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>