fix: correct onError middleware syntax in docs#2537
Conversation
Fixes openapi-ts#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.
👷 Deploy request for openapi-ts pending review.Visit the deploys page to approve it
|
🦋 Changeset detectedLatest commit: 35abf54 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The failing CI tests are in |
Indeed, I've address this in a separate PR a few weeks back which is awaiting review: #2522 |
drwpow
left a comment
There was a problem hiding this comment.
Thank you! Docs changes don’t need a changeset though 🙂
Fixes #2517
Removed nested
onErrorfunction that caused TypeScript error "Cannot find name 'onError'". The correct syntax is to directly return an Error instance from theonErrormethod, not nest anotheronErrorfunction inside it.Changes
onErrorsyntax indocs/openapi-fetch/middleware-auth.mdonErrorsyntax indocs/openapi-fetch/api.mdThe documentation examples now correctly show:
async onError({ error }) {
// wrap errors thrown by fetch
return new Error("Oops, fetch failed", { cause: error });
},Instead of the incorrect nested function syntax that caused TypeScript errors.
How to Review
onErrorexamples in both files now match the correct pattern shown in the test files (packages/openapi-fetch/test/middleware/middleware.test.ts)packages/openapi-fetch/src/index.jsonErrorexamples already in the same documentation files (lines 128-130 in middleware-auth.md)Checklist
docs/updated (if necessary)pnpm run update:examplesrun (only applicable for openapi-typescript)