useFetch API breaks after page transition
See original GitHub issueHello,
I am facing an issue with useFetch()
composable. I am calling my data like so :
// mypage.vue
const config = useRuntimeConfig()
const { data: images } = await useFetch<ImageKit[]>(
'https://api.imagekit.io/v1/files',
{
method: 'GET',
headers: {
Accept: 'application/json',
Authorization: 'Basic ' + config.IMAGEKIT_B64_API
}
}
)
When loading directly the URL http://localhost:3000/mypage
the API is working as expected. However, when coming from another page, I have the following error :
I also have a this in Firefox
I tried the solution posted here without success.
FYI I also tried this in `nuxt.config.ts :
routes: {
'/': {
prerender: true
},
'/*': {
cors: true
}
}
Issue Analytics
- State:
- Created a year ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Error: fetch failed() error on nuxt 3 useFetch() initial API call
Error: fetch failed() Receving this error on initial useFetch() API call with page reloading and sometime it only return the result when we ......
Read more >useFetch - VueUse
Reactive Fetch API provides the ability to abort requests, intercept requests before they are fired, automatically refetch requests when the url changes, ...
Read more >Understanding common frustrations with React Hooks
Calling the useFetch Hook from an event handler breaks the rules of Hooks because you would break the order in which the Hooks...
Read more >Build useFetch Custom React Hook to Fetch Data in 20 Minutes
In this video we will build a powerful Custom React Hook useFetch () that will help us to fetch the data from server...
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
It should probably be:
Yes, that’s exactly the kind of thing you could do. Up to you how to implement it; it depends a bit on your use case.