Grokking React Fundamentals
Vote

0% completed

​

Handling Errors, Cleanup, and Race Conditions with useEffect

A request for an address that does not exist does not make fetch throw an error. The server answers with status 404, and fetch treats any answer as a success.

const response = await fetch("https://jsonplaceholder.typicode.com/postz"); console.log("ok =", response.ok, "status =", response.status);
ok = false status = 404

The promise returned by fetch rejects only when no answer arrives at all, for example when the user is offline or the address cannot be reached

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content