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

json() should also accept a status option #4

Closed
itsMapleLeaf opened this issue Sep 16, 2021 · 4 comments
Closed

json() should also accept a status option #4

itsMapleLeaf opened this issue Sep 16, 2021 · 4 comments
Labels
📦 feature New feature or request

Comments

@itsMapleLeaf
Copy link
Collaborator

A 200 status for all responses works, but being able to give a 4xx for bad responses would definitely feel more proper

@smeijer
Copy link
Owner

smeijer commented Sep 16, 2021

Sounds like a nice addition.

@Siemko
Copy link

Siemko commented Sep 17, 2021

@smeijer I've seen that you've already implemented Responses from node-fetch with ReponseInit, so I believe this one is resolved, correct?

@smeijer
Copy link
Owner

smeijer commented Sep 17, 2021

Correct, I haven't published yet, and want to add a few tests before I do so. But it should be possible with the version on main.

@smeijer
Copy link
Owner

smeijer commented Sep 17, 2021

Published as https://github.com/smeijer/next-runtime/releases/tag/v1.2.0. I'll work on the docs later, but here's an example:

handle({
async get({ req: { method }, res }) {
return json({ method }, { status: 418, statusText: `I\'m a teapot` });
},
}),

@smeijer smeijer closed this as completed Sep 17, 2021
@smeijer smeijer added the 📦 feature New feature or request label Sep 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants