Closed itsmohmans closed 3 months ago
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!
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.
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 ๐
๐ Linked issue
688
โ Type of change
๐ Description
Add
authFetch
composable to provide a way to manually fetch a resource with authorization headers.๐ Checklist