Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error response bug #224

Merged
merged 1 commit into from
Dec 2, 2023
Merged

Fix error response bug #224

merged 1 commit into from
Dec 2, 2023

Conversation

david-crespo
Copy link
Collaborator

Tiny bug introduced in #215, only affected error response on mock server, which we didn't notice because we pretty much only ever see zod error responses when inspecting a mock error response manually in the browser network tab.

const { body, bodyErr } = bodySchema
? validateBody(bodySchema, await req.json())
: { body: undefined, bodyErr: undefined };
if (bodyErr) return json(bodyErr, { status: 400 });
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bodyErr is already a Response, so we were seeing {} as the response body in the browser because JSON.stringify(new Response()) == '{}'.

@david-crespo david-crespo merged commit e9fd215 into main Dec 2, 2023
3 checks passed
@david-crespo david-crespo deleted the fix-validate-body branch December 2, 2023 02:39
@david-crespo david-crespo mentioned this pull request Dec 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant