Question 27
Consider the below JavaScript code.
async function newFetch(url) { try { console.log(url) const res = await fetch(url) if (!res.ok) { throw new Error(`HTTP Error: ${res.status}`) } try { const data = await res.json() console.log(data) } catch { throw new Error('Error') } } catch { throw new Error('Data is not JSON serializable') }}newFetch('https://example.com/api/users/23').catch((err) => { console.error(err)})Suppose the API URL “https://example.com/api/users/23” returns a valid HTML output. What will be logged on to console?
“Network Error”
“HTTP Error: 404”
“Data is not JSON serializable”
Data returned by the API