Skip to content
This repository has been 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
merged 5 commits into from Nov 15, 2022
Merged

Conversation

danielroe
Copy link
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

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
Copy link
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
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
Member

pi0 commented Nov 15, 2022

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

@danielroe
Copy link
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
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
Member Author

excellent

@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

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

@manniL
Copy link
Member

manniL commented Dec 22, 2022

@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
4 participants