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

docs: add custom fetch composable example #20115

Merged
merged 22 commits into from Apr 26, 2023

Conversation

adrienZ
Copy link
Sponsor Contributor

@adrienZ adrienZ commented Apr 6, 2023

πŸ”— Linked issue

#14736

❓ 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

Adds an example in the other folder of custom use fetch composable. It handles default values and auth but can be overriden.

πŸ“ Checklist

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

@codesandbox
Copy link

codesandbox bot commented Apr 6, 2023

CodeSandbox logoCodeSandbox logoΒ  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@nuxt-studio
Copy link

nuxt-studio bot commented Apr 6, 2023

βœ… Live Preview ready!

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

@adrienZ adrienZ force-pushed the docs/fetch-composable-exemple branch 2 times, most recently from 6dbbc79 to 3a7f42b Compare April 6, 2023 18:10
@danielroe danielroe requested a review from Atinux April 7, 2023 08:34
@danielroe danielroe changed the title docs: custom fetch composable exemple #14736 docs: custom fetch composable example Apr 7, 2023
@adrienZ adrienZ force-pushed the docs/fetch-composable-exemple branch from 2014a10 to 9baf841 Compare April 7, 2023 08:40
}

// for nice deep defaults, please use unjs/defu
const params = Object.assign(defaults, options)
Copy link
Member

Choose a reason for hiding this comment

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

nice idea! let's go ahead and use defu then

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

updated :)

Comment on lines 16 to 18
if (userAuth.value) {
options.headers.Authorization = `Bearer ${userAuth.value}`
}
Copy link
Member

Choose a reason for hiding this comment

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

we might also need to handle the case where this is a Headers object and we need to do headers.set(). For simplicity, is there any reason not to use the headers: {} option directly instead of within onRequest?

Copy link
Sponsor Contributor Author

Choose a reason for hiding this comment

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

tried something simpler :)

Copy link
Member

@danielroe danielroe left a comment

Choose a reason for hiding this comment

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

Thanks!

@danielroe danielroe changed the title docs: custom fetch composable example docs: add custom fetch composable example Apr 26, 2023
@danielroe danielroe merged commit a21a520 into nuxt:main Apr 26, 2023
18 checks passed
@github-actions github-actions bot mentioned this pull request Apr 26, 2023
@adrienZ adrienZ deleted the docs/fetch-composable-exemple branch April 26, 2023 11:42
@adrienZ
Copy link
Sponsor Contributor Author

adrienZ commented Apr 26, 2023

should we close #14736 ?

@danielroe
Copy link
Member

We also need to add some composables for modifying the inner behaviour of the data fetching composables, much as we have defineNuxtLink.

@github-actions github-actions bot mentioned this pull request Apr 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants