I am attempting to scrape news articles from a site using fetch and promise all. Example found here
Here is the code I am using.
var openArticles = function(urlArray){
Promise.all(urlArray.map(u=>fetch(u))).then(responses =>
Promise.all(responses.map(res => res.text()))
).then(function(html){
console.log(html[0])
})
};
I am not too familiar with arrow function expressions and am having a difficult time with adding error handling for 500 and timeout errors. I tried putting code in try catch block but that did not help, and I am not sure where or how to enter if statement to check response status. Is there a way to rewrite this using standard function name() format?