Question 16
Consider the following 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 there is an network error and fetch request to the ‘url’ fails. What will be logged on to console, if the code is executed?
Response is not json
Network Error
200
None of these.