question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Nuxt3.0.0-rc.13] UseFetch() when calling multiple request, only the last data is fetched.

See original GitHub issue

Environment

Nuxi 3.0.0-rc.13

  • Operating System: Darwin
  • Node Version: v16.18.0
  • Nuxt Version: 3.0.0-rc.13
  • Nitro Version: 0.6.1
  • Package Manager: yarn@1.22.18
  • Builder: vite
  • User Config: ssr, target, meta, css, plugins, vite, build, modules, buildModules, typescript, components, vueuse, publicRuntimeConfig
  • Runtime Modules: @vueuse/nuxt@9.5.0
  • Build Modules: @pinia/nuxt@0.4.3, unplugin-icons/nuxt

Reproduction

Page L component_1.vue L component_2.vue L conponent_3.vue

component_1 ` onMounted(() => { request(‘firstUrl’) })

const request = async (url:string) => { const { data } = await useFetch(url, options) console.log(data) } `

component_2 ` onMounted(() => { request(‘secondUrl’) })

const request = async (url:string) => { const { data } = await useFetch(url, options) console.log(data) } `

component_3 ` onMounted(() => { request(‘thirdUrl’) })

const request = async (url:string) => { const { data } = await useFetch(url, options) console.log(data) } `

Describe the bug

My pages folder tree

in each component(tabs), Each component requested the following api calls in the onMounted lifecycle.

However, among the above three requests, I found that the data of the last request data goes into each result(component_1, component_2 result).

useFetch() <- not working Async / await ?

you can find my log below,

As I expected, the response value should come right below each url, but the last data comes 3 times after all url have been delivered. (see, logs) what should i do? help me:)

useFetch() can use 3.0.0-rc.8.

Additional context

No response

Logs

orders/usim/delivery/before/1/20
orders/usim/delivery/after/1/20
orders/usim/1/20
Proxy {success: true, data: {…}}[[Handler]]: Object[[Target]]: Objectdata: {list: Array(20), count: 1649}success: true[[Prototype]]: Object[[IsRevoked]]: false
Proxy {success: true, data: {…}}[[Handler]]: Object[[Target]]: Objectdata: {list: Array(20), count: 1649}success: true[[Prototype]]: Object[[IsRevoked]]: false
Proxy {success: true, data: {…}}[[Handler]]: Object[[Target]]: Objectdata: {list: Array(20), count: 1649}success: true[[Prototype]]: Object[[IsRevoked]]: false

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
yeonjulee1005commented, Nov 9, 2022

Thank you for helping me! I’ll write it up and post it!

1reaction
danielroecommented, Nov 9, 2022

Please see the link I posted. I don’t need your project, but I do need a stackblitz that shows the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

UseFetch() calling multiple request, only the last data ... - GitHub
when i use $fetch instead of useFetch, it works good but it makes another problem for me... on refreshing page,it send a request...
Read more >
useFetch in Nuxt3 keeping cached data - vue.js - Stack Overflow
If I refresh the said page with old data, it works ok. This seems to be happening because the new slug's api call...
Read more >
Nuxt3 doesn't fetch new data after client-side navigation : r/Nuxt
I'm struggling with data fetching in Nuxt3. ... initialCache: false as a parameter to useFetch() - NOTE: This will make every single call...
Read more >
Data Fetching - Nuxt
In Nuxt we have 2 ways of getting data from an API. ... fetchOnServer : Boolean or Function (default: true ), call fetch()...
Read more >
Creating Server-side Rendered Vue.js Apps Using Nuxt.js
Afterward, we would set loading = false and display the data. Instead, let's use fetch to populate the Store before rendering. In a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found