Skip to content

Glossary: JavaScript in the Browser

HttpError and fetchJSON

Also written: HttpError, fetchJSON, postJSON

A custom error class and a helper function that turn every `fetch` failure into a thrown error. `fetchJSON` throws an `HttpError` carrying the status and body for any bad status, so a single `catch` can handle all failures.

Where the book teaches it

Related terms

fetchFour states (loading, loaded, empty, failed)