Question 9
Consider the following javascript code.
async function fetchData() { try { const response = await fetch('https://api.example.com/data'); if (!response.ok) throw new Error('HTTP error'); const data = await response.json(); return data; } catch (error) { if (error.name === 'TypeError') { return { status: 'network error' }; } return { status: 'http error' }; }}When the function is called what will be returned if the server is unreachable?
{ status: 'http error' }
{ status: 'network error' }
undefined
The promise will remain pending