This repository has been archived by the owner on Apr 6, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
docs: add description of returning different status codes #10059
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add description of how to use `createError` and `event.node.res.statusCode` from server directory
|
danielroe
reviewed
Jan 19, 2023
danielroe
reviewed
Jan 19, 2023
danielroe
reviewed
Jan 19, 2023
danielroe
reviewed
Jan 19, 2023
danielroe
reviewed
Jan 19, 2023
danielroe
reviewed
Jan 19, 2023
danielroe
approved these changes
Jan 19, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
β Type of change
π Description
Add description of how to use
createError
andevent.node.res.statusCode
from server directory.There is already documentation of createError on https://nuxt.com/docs/api/utils/create-error#throwing-errors-in-api-routes. However I think this is a common enough use case, that it should be documented directly on https://nuxt.com/docs/guide/directory-structure/server.
For documentation of how to use non error status code, I couldn't find anything in the docs for server routes. I found https://nuxt.com/docs/api/utils/set-response-status, however this doesn't seem to work for server routes.
As a personal anecdote, I had to implement different status codes. I expected to find a guide in the server routes documentation, but I had to do some more searching. To set non error status codes I had to look in the h3 docs.
π Checklist