Title: Fetch Error Details in JavaScript - Runnable Code Snippet
Open Graph Title: Fetch Error Details in JavaScript - Runnable Code Snippet
X Title: Fetch Error Details in JavaScript - Runnable Code Snippet
Description: Extract status, headers and body from an HTTP error response. Runnable JavaScript snippet with live execution.
Open Graph Description: Extract status, headers and body from an HTTP error response. Runnable JavaScript snippet with live execution.
X Description: Extract status, headers and body from an HTTP error response. Runnable JavaScript snippet with live execution.
Keywords:
Opengraph URL: https://tempercode.dev/snippets/fetch-error-details-javascript
Domain: tempercode.dev
{"@context":"https://schema.org","@type":"SoftwareSourceCode","name":"Fetch Error Details","description":"Extract status, headers and body from an HTTP error response.","programmingLanguage":"JavaScript","text":"const res = await fetch('https://httpbin.org/status/500');\nconst body = await res.text();\nreturn {\n ok: res.ok,\n status: res.status,\n statusText: res.statusText,\n headers: Object.fromEntries(res.headers),\n body\n};"}
| theme-color | #0c0d12 |
| color-scheme | dark |
| author | Temper |
| creator | Temper |
| publisher | Temper |
| og:image | https://tempercode.dev/og-image.png |
| og:type | article |
| twitter:card | summary_large_image |
| twitter:image | https://tempercode.dev/og-image.png |
Links:
Viewport: width=device-width, initial-scale=1