Skip to content

Commit d37b082

Browse files
authored
fix: correct onError middleware syntax in docs (#2537)
* fix: correct onError middleware syntax in docs Fixes #2517 Removed nested onError function that caused TypeScript error. The correct syntax is to directly return an Error instance from the onError method, not nest another onError function inside it. * chore: add changeset for middleware onError docs fix
1 parent dc80e26 commit d37b082

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"openapi-fetch": patch
3+
---
4+
5+
Fix incorrect `onError` middleware docs example that caused a TypeScript error when copy-pasted.
6+
7+

docs/openapi-fetch/api.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,7 @@ const myMiddleware: Middleware = {
242242
},
243243
async onError({ error }) {
244244
// wrap errors thrown by fetch
245-
onError({ error }) {
246-
return new Error("Oops, fetch failed", { cause: error });
247-
},
245+
return new Error("Oops, fetch failed", { cause: error });
248246
},
249247
};
250248

docs/openapi-fetch/middleware-auth.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ const myMiddleware: Middleware = {
2929
},
3030
async onError({ error }) {
3131
// wrap errors thrown by fetch
32-
onError({ error }) {
33-
return new Error("Oops, fetch failed", { cause: error });
34-
},
32+
return new Error("Oops, fetch failed", { cause: error });
3533
},
3634
};
3735

0 commit comments

Comments
 (0)