Skip to content

Commit ff57082

Browse files
authored
Fix middleware docs (#1976)
* Fix throwing middleware example * add changeset * Delete .changeset/.changeset/silver-wasps-relate.md
1 parent 781cf92 commit ff57082

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/openapi-fetch/middleware-auth.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ Middleware can also be used to throw an error that `fetch()` wouldn’t normally
6464

6565
```ts
6666
onResponse({ response }) {
67-
if (response.error) {
68-
throw new Error(response.error.message);
67+
if (!response.ok) {
68+
// Will produce error messages like "https://example.org/api/v1/example: 404 Not Found".
69+
throw new Error(`${response.url}: ${response.status} ${response.statusText}`)
6970
}
7071
}
7172
```

0 commit comments

Comments
 (0)