Skip to content

Commit

Permalink
docs: recommend .end instead of .send when no body is being sent (#…
Browse files Browse the repository at this point in the history
…33611)

Fixes #33536

I was thinking to make `body` optional here instead:

https://github.com/vercel/next.js/blob/2c6bd1ed1b3821debda74dc8f407b8f11779a4f0/packages/next/shared/lib/utils.ts#L262

But that might result in more errors when not setting the status code correctly. So it's the easiest for us to just recommend `.end()` which `.send()` uses when there is no argument.

https://github.com/vercel/next.js/blob/c71465d87a7eeb050e5cc7e94817f19e69e9d1e4/packages/next/server/api-utils.ts#L269

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
  • Loading branch information
balazsorban44 committed Feb 3, 2022
1 parent bc223d7 commit b772513
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion errors/invalid-api-status-body.md
Expand Up @@ -22,7 +22,7 @@ After

```js
export default function handler(req, res) {
res.status(204).send()
res.status(204).end()
}
```

Expand Down

0 comments on commit b772513

Please sign in to comment.