All Challengesbeginner
Spot the async pattern
AI generates this pattern constantly when fetching data from an API.
javascript
async function getUser(userId) {
try {
const response = await fetch(`/api/users/${userId}`)
const data = await response.json()
return data
} catch (error) {
console.error('Failed to fetch user:', error)
return null
}
}Question
What does this function return if the API call fails?