Question 17
Consider the JavaScript code.
async function getResponse(url) { try { const response = await fetch(url) try { const data = await response.json() if (response.ok) { return data } else { return response.status } } catch { return 'Network Error' } } catch { return 'Response is not json' }}
getResponse('url').then((data) => { console.log(data)})Suppose the ‘url’ returns a JSON response with 500 status code. What will be logged on to console?
Response is not json
Network Error
404
500