null response on load of the nested child when using useLazyFetch on bridge
See original GitHub issueDiscussed in https://github.com/nuxt/framework/discussions/3083
<div type='discussions-op-text'>Originally posted by csechuan February 7, 2022
Reproduction
https://github-rxxzhp-cpxf9c–3000.local.webcontainer.io/
Steps
- Open your console
- Click “Go cinema”
- Click “Watch movie”
// console output
movie env client res {"data":{"value":null},"pending":{"value":true},"error":{"value":null}}
- Click “Back”
- Click “Go cinema” again
// console output
movie env client res {"data":{"value":{A_LOT_OF_DATA_HERE}},"pending":{"value":true},"error":{"value":null}}
// check the network tab for movie. you should see the API response fine.
- Repeating steps 4-5 will have the same result
Description of the bug
Fetch response does not have data on first try. Subsequently it prints some data.
Additional context
Besides, i found another bug during debugging this issue. The pending
flag is always true when useLazyFetch
runs on client. I may not use the function correctly.
<script setup>
// since vue2 on nuxt bridge cant use top-level await
useLazyFetch('URL_HERE').then(res => console.log(res))
</script>
</div>Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
nuxt.js - Why does useLazyFetch composable returns null data?
I am trying to learn how to use the ...
Read more >Learn All About PHP Functions with Examples
In this article, we will learn about PHP functions together with examples. ... When a page loads, a feature will not run automatically....
Read more >nuxt: Versions | Openbase
Nuxt's node server renderer will now respond with 103 Early Hints before the server ... nuxt: Load payload after middleware and once final...
Read more >Data Fetching · Get Started with Nuxt
It automatically generates a key based on URL and fetch options, provides type hints for request url based on server routes, and infers...
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
The data from
useLazyFetch
isn’t meant to be used within the setup function (that’s why it’slazy
). Instead it returns a reactive ref that gets filled in later. So you handle it like this: https://v3.nuxtjs.org/docs/usage/data-fetching#example-3sorry. terrible mistake. didnt notice that. try this
https://stackblitz.com/edit/github-rxxzhp-cpxf9c