scrimba
Frontend Career Path
Advanced React
React Router
Coding the Sad Path - Error handling
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Coding the Sad Path - Error handling
AboutCommentsNotes
Coding the Sad Path - Error handling
Expand for more info
api.js
run
preview
console
export async function getVans() {
const res = await fetch("/api/vans")
if (!res.ok) {
throw {
message: "Failed to fetch vans",
statusText: res.statusText,
status: res.status
}
}
const data = await res.json()
return data.vans
}
Console
!
{message:
"Failed to fetch vans"
, statusText:
"Bad Request"
, status:
400
}
,
/vans
-5:59