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

Add async to middleware docs. #31356

Merged
merged 4 commits into from Feb 6, 2022
Merged

Add async to middleware docs. #31356

merged 4 commits into from Feb 6, 2022

Conversation

ncphillips
Copy link
Contributor

@ncphillips ncphillips commented Nov 12, 2021

I was reading the docs and got nervous. It looked like middleware didn't support async/await. After digging into the examples I found out it is possible.

Not 100% sure if this is the docs change yahs want, but I thought I'd open a PR just incase.

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

I was reading the docs and got nervous. It looked like middleware didn't support async/await. After digging into the examples I found out it is possible. 

Not 100% sure if this is the docs change yahs want, but I thought I'd open a PR just incase.
@molebox
Copy link
Contributor

molebox commented Nov 12, 2021

Hey @ncphillips we do mention this in the middleware docs on the vercel docs site. Good catch that we don't mention it here. I think I'd rather we add the same note (copy) that we have on the vercel docs.

The reason being that if we make the function async in the first example, folks might think that it has to be async, in much the same way that you thought that it doesn't have to be 🙃

If you would like to add it, you can find it here just scroll down a tad.

Thank you!

@ijjk ijjk dismissed a stale review via 0fb5fe2 February 6, 2022 01:50
Copy link
Member

@ijjk ijjk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@ijjk ijjk merged commit 7309098 into vercel:canary Feb 6, 2022
natew pushed a commit to natew/next.js that referenced this pull request Feb 16, 2022
* Add `async` to middleware docs. 

I was reading the docs and got nervous. It looked like middleware didn't support async/await. After digging into the examples I found out it is possible. 

Not 100% sure if this is the docs change yahs want, but I thought I'd open a PR just incase.

* Add middleware API note

Co-authored-by: JJ Kasper <jj@jjsweb.site>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants