Skip to content

Shortcut to set response status code #14474

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

Closed
3 of 4 tasks
pi0 opened this issue Aug 2, 2022 · 0 comments · Fixed by nuxt/framework#6306
Closed
3 of 4 tasks

Shortcut to set response status code #14474

pi0 opened this issue Aug 2, 2022 · 0 comments · Fixed by nuxt/framework#6306
Assignees

Comments

@pi0
Copy link
Member

pi0 commented Aug 2, 2022

Describe the feature

Generally, errors can be thrown with showErrorPage or throw createError() but sometimes, a soft error behavior (as described by @danielroe) is needed, it is better to practice to also set valid response code, even if not using error/404 pages.

As suggested by @atinux, it could be nice if we introduce a shortcut utility for useRequestEvent().res.statusCode = 404.

I suggest:

setResponseStatusCode(code: number)

Additional information

  • Would you be willing to help implement this feature?
  • Could this feature be implemented as a module?

Final checks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants