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: Add a composable to make authenticated requests #787

Closed
wants to merge 5 commits into from

Conversation

itsmohmans
Copy link

πŸ”— Linked issue

#688

❓ 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

Add authFetch composable to provide a way to manually fetch a resource with authorization headers.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have added tests (if possible).
  • I have updated the documentation accordingly.

@zoey-kaiser
Copy link
Member

zoey-kaiser commented Jul 5, 2024

Hi @itsmohmans πŸ‘‹

Thank you for your contribution! While I think it is really cool to add these kinds of utilities to the module, I think we should approach it slightly differently:

Let us provide a more generic: headers computed that only returns the required headers for the request. This would allow people to use the utility for other HTTP clients such as Axios. It would also avoid us having to hard-depend on the Nuxt $fetch methods and allow users to choose between using $fetch, useFetch, or useAsyncData without us writing custom wrappers for each.

Alternatively, if we did want to add custom wrappers for the fetch functions of Nuxt I would propose adding a new composable to handle this.

I will also pull in @phoenix-ru for his opinion on this matter!

@zoey-kaiser zoey-kaiser changed the title Add a composable to make authenticated requests feat: Add a composable to make authenticated requests Jul 5, 2024
@itsmohmans
Copy link
Author

itsmohmans commented Jul 6, 2024

Hey @zoey-kaiser!
I agree it should be more generic; However, wouldn't a headers computed be somewhat similar to the current token property as we can just add it to the request headers along with anything else we want to add in the request?

I still do think the module needs a composable that makes authenticated requests out of the box, but I'm open for edits on how we approach this in a better way in order to work well with all other tools as well.

@zoey-kaiser
Copy link
Member

Hi @itsmohmans πŸ‘‹

I would propose we close this Pull request and discuss some of the options we outlined above in #688. Like I mentioned beforehand, I generally do like this idea, however would like to ensure we add this correctly and provide as much utility as possible!

Therefore, let's go back to the drawing board and discuss some new options 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants