Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

docs: add description of returning different status codes #10059

Merged
merged 7 commits into from
Jan 19, 2023

Conversation

MikeBellika
Copy link
Contributor

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

Add description of how to use createError and event.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

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Add description of how to use `createError` 
and `event.node.res.statusCode` from server directory
@codesandbox
Copy link

codesandbox bot commented Jan 12, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@MikeBellika MikeBellika changed the title docs: add description of returning status codes docs: add description of returning different status codes Jan 12, 2023
@danielroe danielroe added the documentation Improvements or additions to documentation label Jan 13, 2023 — with Volta.net
@danielroe danielroe merged commit 49a2dd5 into nuxt:main Jan 19, 2023
@danielroe danielroe added the 3.x label Jan 19, 2023
@danielroe danielroe mentioned this pull request Jan 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
3.x documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants