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

feat(nuxt): useRequestHeader utility #24781

Merged
merged 19 commits into from Dec 16, 2023
Merged

Conversation

GalacticHypernova
Copy link
Contributor

@GalacticHypernova GalacticHypernova commented Dec 15, 2023

πŸ”— Linked issue

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 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)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

The current request header retrival process of useRequestHeaders is a bit unintuitive in situations that require reading headers. It doesn't make a lot of sense from a developmental standpoint as more often than not you would need only a single header, mostly for "reading" operations (I myself have a couple of such use cases, for example, authorization middleware).
This PR provides that possibility to simplify and improve DX. With this a person could simply do

const cookie = useRequestHeader('cookie')

That being said, I would like to reiterate and clarify that this is not a replacement of getRequestHeaders. This can be used to directly read header values when dealing with authorization related middleware for example, whereas getRequestHeaders can be used to proxy the headers and use them in API calls, due to its object return.

πŸ“ Checklist

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

Copy link

stackblitz bot commented Dec 15, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@GalacticHypernova GalacticHypernova marked this pull request as draft December 15, 2023 14:05
@github-actions github-actions bot added the 3.x label Dec 15, 2023
@GalacticHypernova
Copy link
Contributor Author

GalacticHypernova commented Dec 15, 2023

Marking this a draft to write the documentation and make any necessary changes.

Copy link

nuxt-studio bot commented Dec 15, 2023

βœ… Live Preview ready!

Name Edit Preview Latest Commit
Nuxt Docs Edit on Studio β†—οΈŽ View Live Preview 186b654

@GalacticHypernova
Copy link
Contributor Author

GalacticHypernova commented Dec 15, 2023

Should I also clarify in the docs that this is used as an abstraction of useRequestHeaders in specific header-related operations (like the example I already provided in the docs)?

@danielroe
Copy link
Member

Sure, it would be good to point people to the upstream utility used πŸ‘

@Atinux
Copy link
Member

Atinux commented Dec 15, 2023

Thank you! Indeed it is useful to be able to get one specific header πŸ‘

GalacticHypernova and others added 2 commits December 15, 2023 21:05
Co-authored-by: Damian GΕ‚owala <damian.glowala.rebkow@gmail.com>
@GalacticHypernova GalacticHypernova marked this pull request as ready for review December 16, 2023 08:41
@danielroe danielroe merged commit 40a5f44 into nuxt:main Dec 16, 2023
36 checks passed
@github-actions github-actions bot mentioned this pull request Dec 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants