Skip to content

Commit ca728d4

Browse files
authored
Fix throwing middleware example
1 parent 781cf92 commit ca728d4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/openapi-fetch/middleware-auth.md

Lines changed: 3 additions & 2 deletions
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)