`useFetch` does not refresh when a params object is used
See original GitHub issueEnvironment
Linux
Reproduction
Go to: https://stackblitz.com/edit/github-mt2nv8?file=app.vue
Try to increase the page by pressing the respective button. The same request is performed with each button press.
As described in the sandbox, using the _start
param as part of the url works properly.
Describe the bug
The refresh
function of the useFetch
composable does not properly refresh requests that depend on params object instead of params in the url itself.
Additional context
No response
Logs
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
useFetch refresh not working when params change #5653
This is how Vue reactivity works - the value is frozen in time when you call useFetch : see #4970. If you want...
Read more >useFetch of Nuxt 3 sends same request during refresh ...
I've created a pull request on nuxt/framework to have it reflected in the documentation. Please see a full explanation below: Using the query ......
Read more >useFetch
It's an isomorphic fetch hook. That means it works with SSR (server side rendering). A note on the documentation below. Many of these...
Read more >Fetching Data and Updating State with React Hooks
The guide detailed how to do this with the componentDidMount() lifecycle method that every React class component provides. Many components, ...
Read more >useFetch
The useFetch function can be used by simply providing a url. The url can be either a string or a ref . The...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes. You should instead use it in the URL directly as I have done above, as the params are ‘frozen’ in time when the setup function runs. (This is not unique to Nuxt, but is a caveat of Vue reactivity.)
when using it in url, the response type cannot be solved in typescript. type will become
unknown
. I suggest we can have something like