-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
docs: add custom useFetch recipe #27208
Conversation
Run & review this pull request in StackBlitz Codeflow. |
I'm using a similar setup with both |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would generally suggest replacing vast majority of occurences of 'we' (e.g. 'we created', 'we are storing') with a form more commonly used in the docs.
E.g. given the following sentence:
We are currently discussing with the core team (...)
... who are 'we' to the readers if it isn't the core team?
Might be worth linking https://www.youtube.com/watch?v=jXH8Tr-exhI here too (happy to link back to the blog post instead of your personal one after this was published 👌) |
Co-authored-by: Damian Głowala <damian.glowala.rebkow@gmail.com>
Co-authored-by: Damian Głowala <damian.glowala.rebkow@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've pushed a couple of changes, including to the example (for handling different possibilities of HeadersInit
). It would be worth checking that everything still works as expected.
what do you think @Atinux?
@Atinux Will this duplicate https://nuxt.com/docs/examples/advanced/use-custom-fetch-composable ? Should this example be deleted ? |
@maximepvrt I created a PR on nuxt/examples#75 to update the link I think we could update the example based on Daniel changes though. @danielroe it would be nice to have a utility for that because having 3 lines to do the same thing is quite frustrating. @pi0 is this something that Thinking of: const api = $fetch.create({
baseURL: 'https://api.nuxt.com',
onRequest({ setHeader }) {
if (session.value?.token) {
setHeader('Authorization', `Bearer ${session.value?.token}`)
}
}
}) |
@DamianGlowala applied the changes. @manniL linked your video :) |
Having standard way in ofetch context to set/get headers seems good idea. I'm thinking to adopt usage of web |
@Atinux Now that it has been merged, do you think it'd be helpful to link to the post in the docs in your blog post on the top of the article? 😋 |
@manniL I added a redirect instead :) |
Migrate from https://notes.atinux.com/nuxt-custom-fetch to a Nuxt recipe as it has a lot of traffic and helps many people on this important feature.