Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

fix(nuxt)!: include request url and params in useFetch key#6632

Merged
pi0 merged 5 commits intomainfrom
fix/fetch-url-key
Nov 15, 2022
Merged

fix(nuxt)!: include request url and params in useFetch key#6632
pi0 merged 5 commits intomainfrom
fix/fetch-url-key

Conversation

@danielroe
Copy link
Copy Markdown
Member

@danielroe danielroe commented Aug 15, 2022

🔗 Linked issue

resolves nuxt/nuxt#14493, resolves nuxt/nuxt#14499

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 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)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

A regression of #4955 - we were not using the URL as a key if it was provided. This PR uses the url as default key (including params and baseURL if provided).

There is still room for future improvement here via nuxt/nuxt#14583, for example, and I'll be following up with some more PRs targeting specific issues.

📝 Checklist

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

@danielroe danielroe added bug Something isn't working 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage labels Aug 15, 2022
@danielroe danielroe requested a review from pi0 August 15, 2022 10:43
@danielroe danielroe self-assigned this Aug 15, 2022
@netlify
Copy link
Copy Markdown

netlify Bot commented Aug 15, 2022

Deploy Preview for nuxt3-docs failed.

Name Link
🔨 Latest commit 4826776
🔍 Latest deploy log https://app.netlify.com/sites/nuxt3-docs/deploys/6373c1550b37a0000827135a

@pi0 pi0 added the pending label Aug 15, 2022
@pi0 pi0 force-pushed the main branch 2 times, most recently from 247e18b to c98e5c7 Compare September 14, 2022 10:41
Comment thread packages/nuxt/src/app/composables/fetch.ts Outdated
@pi0
Copy link
Copy Markdown
Member

pi0 commented Nov 10, 2022

Any update on this @danielroe ? Last time we discussed i think we decided to combination of auto key and hash.

@danielroe
Copy link
Copy Markdown
Member Author

@pi0 Sure! Would you summarise what the issues are from your point of view, apart from hashing the url key?

@pi0
Copy link
Copy Markdown
Member

pi0 commented Nov 15, 2022

Async data key to be {key||autokey}-{hash(input)}. Does it makes sense?

@danielroe
Copy link
Copy Markdown
Member Author

How about instead: options.key || ((no functional options) ? hash(url + options) : autoKey)?

The reason is that any hash of input options is going to mismatch between server + client if any of those options are functions.

@pi0
Copy link
Copy Markdown
Member

pi0 commented Nov 15, 2022

By hash i mean url+query only not all options.

seems good idea to allow entirely overriding with custom key 👍

@danielroe
Copy link
Copy Markdown
Member Author

excellent

@danielroe danielroe requested a review from pi0 November 15, 2022 16:34
@vercel vercel Bot temporarily deployed to Preview November 15, 2022 16:35 Inactive
Comment thread packages/nuxt/src/app/composables/fetch.ts Outdated
@pi0 pi0 changed the title fix(nuxt): use url as fetch key if none other is provided fix(nuxt)!: include request url and params in useFetch key Nov 15, 2022
@pi0 pi0 merged commit f785052 into main Nov 15, 2022
@pi0 pi0 deleted the fix/fetch-url-key branch November 15, 2022 16:47
@examgoal
Copy link
Copy Markdown

The fetch options key not working anymore! I think it broke it, please check again

@TheAlexLichter
Copy link
Copy Markdown
Member

@examgoal Please create a new issue with reproduction ☺️

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

3.x bug Something isn't working 🔨 p3-minor-bug Priority 3: a bug in an edge case that only affects very specific usage pending

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate response when calling a composable with useLazyFetch inside Page Route not refresh the template request data

4 participants