useAsyncData vs. useFetch 🤯

  Рет қаралды 9,963

Alexander Lichter

Alexander Lichter

Күн бұрын

Пікірлер: 68
@valacshiro378
@valacshiro378 7 ай бұрын
Thank you again, I really like your videos and examples, even though I watched all it will be helpful to include the link or the video when you mention it :) Thanks again for keeping it going 🙏
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Thanks for the suggestion! I include all links in the descriptions and videos as cards in the corner of the video (+ in the description ☺️)
@KefiVitcH
@KefiVitcH 7 ай бұрын
Your content is great and the way you explain things is awesome ! here is a small advice: thhe noise cancelling is cutting some words some time. You may need to reduce it ;)
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
Thanks for the tip! Will revisit my gate settings 👌
@DavidDeSloovere
@DavidDeSloovere 7 ай бұрын
For other that may wonder, I asked copilot “Why the name $fetch?” Instead of ofetch: - The name $fetch is chosen for consistency and ease of use. - It aligns with Vue’s convention of prefixing instance properties with a dollar sign (e.g., $data, $props, $emit).
@AksoomHussain7866
@AksoomHussain7866 7 ай бұрын
your videos are great help to understand behind seen, nowadays i see most nuxt video cover composables and predefined function majorly , i would like you to explore layouts as it seem less explored part of nuxt like implementing persistence layout, nested layout and hook functions in nuxt, may be your tricks help in IRL work
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
Glad they help 🙏🏻 I put nested layouts on the list 👍🏻 Hooks are also interesting but they need specific use cases ☺️
@codewithguillaume
@codewithguillaume 7 ай бұрын
Yess!!!!!
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
Haha, waited for this one for a while? 😁
@freekeys
@freekeys 3 ай бұрын
useAsyncData is more like useEffect in react that has watcher
@alimaher1
@alimaher1 7 ай бұрын
As always, great content! Also, I have a question; Is it okay to use Nuxt with complete Client side rendering (Full SPA)? In my work, they can't afford ssr, should I go with nuxt to get all the benefits or it would be overhead?
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
Yes, absolutely! You can build a plain old SPA with Nuxt if you don't need SSR!
@Tarabass
@Tarabass 7 ай бұрын
Nice video, as always! How do you do that, talking at conferences and posting video's on yt at the same time lol 😅
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
Haha, just because I am not there I can't let the people wait for the content 😁 Though I didn't do many announcements around (will do that on Monday) Was nice meeting you in person!
@shuanwang4227
@shuanwang4227 6 ай бұрын
This is very helpful! Thank you always.
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
You're so welcome! 🙌
@barbapapazes
@barbapapazes 7 ай бұрын
Perfect explanation once again! 👌
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
Thank you! 🙌
@QueeeeenZ
@QueeeeenZ 7 ай бұрын
It would also be nice to see how to build useAsyncData from scratch and how it works under the hood.
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
Great idea! Added to the list 👌
@virusblitz
@virusblitz 7 ай бұрын
Amazing video as alsways! Perfect topic as always :D
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
Glad you think so! 👌 Let me know if you have any ideas or topics in mind!
@Дмитрий-л4с9х
@Дмитрий-л4с9х Ай бұрын
Thank you for your video! Could you please give me an advice. I wanna make the app which can be managed in both directions: if i change my reactives, data will changes and if i come from another page with pre-set query, the data should be correct. Struggling with that 😵 P.s. Using useAsyncData
@TheAlexLichter
@TheAlexLichter Ай бұрын
You are welcome! Both ways should work by "watching" the route query I'd say 🤔
@chstappert
@chstappert 7 ай бұрын
Thanks a lot for this important insight!
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
Glad it was helpful! 🙌
@MrSimpleCF
@MrSimpleCF 7 ай бұрын
I love you man, always helpful and super insightful
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
You are welcome! Glad I can help 🙏🏻
@jahongirsalimov9587
@jahongirsalimov9587 7 ай бұрын
awesome as usual! Thank you !
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
Thank you! Glad it helps 🙌
@nhs119nhs119
@nhs119nhs119 7 ай бұрын
Like your videos more and more, great job as always!
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
Thank you very much! Is there anything on your mind that could be better? 😊
@barbapapazes
@barbapapazes 7 ай бұрын
That thumbnail is so fun 😂
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
A hilarious one every now and then 😛
@buxtehude578
@buxtehude578 7 ай бұрын
Thank you. Could you kindly elaborate on why the useFetch function isn't universally applicable? It feels like a design flaw ... akin to React's approach, requiring users to be aware of specific exceptions, e.g. when dealing with all of their hooks.
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
What exactly do you mean with "isn't universally applicable"? That you can only use it in a Vue context? 👀 (Related: kzbin.info/www/bejne/pJvWeImjmLypn7s )
@buxtehude578
@buxtehude578 7 ай бұрын
@@TheAlexLichter Thank you for getting back. As highlighted in both the documentation and the video, it's emphasized that useFetch is intended for data fetching in a component setup function, while $fetch is better suited for making network requests triggered by user interaction.
@gomesbruno201
@gomesbruno201 Ай бұрын
so, is useAsyncData like react's useMemo with a different life cycle?
@fmoessle
@fmoessle 7 ай бұрын
as always: thank you :)
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
My pleasure! 😊
@gabrielserejo8379
@gabrielserejo8379 7 ай бұрын
nice video alex!
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
Glad you enjoyed it 😋
@LB-q7m
@LB-q7m 3 күн бұрын
Hi great tutorial. I am using useAsyncData with a handler function that performs multiple $fetch's within to populate page data (as I am hitting a few different apis). But when in my /server/api route I am seeing it is getting called twice. Any ideas on a solution?
@TheAlexLichter
@TheAlexLichter 2 күн бұрын
Do you possibly have 2 components calling the same API?
@LB-q7m
@LB-q7m 2 күн бұрын
@@TheAlexLichter I think I got the issue sorted on dev mode. But I notice on prod it's hitting the API twice, almost like it's rendering the page twice or hitting it client and server side at the same time.
@_parassolanki
@_parassolanki 7 ай бұрын
It would be nice to have composable for mutation like `useMutation` available in tanstack query currently for mutation we can't use useFetch and it does not success, error callbacks.
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
You could use useFetch with interceptors though, couldn't you? 🤔
@ArnoldGotClips
@ArnoldGotClips 7 ай бұрын
'DX' is short form for what?
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
Developer Experience ☺️
@ElTebe
@ElTebe 7 ай бұрын
How can the above methods be leveraged, for example, in the case of an AWS Amplify GraphQL call?
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
Same idea, but using POST. I'd probably use a dedicated GQL lib/module though
@DevMarques
@DevMarques 7 ай бұрын
Great video as always. How would you leverage useFetch with a repository pattern? My whole repository file is sustained on something like this and the same query might at some point be triggered by user interaction (which triggers a warning when using useFetch) or just plain data fetching (which works just fine): import type {$Fetch, NitroFetchRequest} from 'nitropack' import type {ApiResponse, ApiResponseWithCursorMeta} from "~/types/responses.generics.interface"; export const eventsRepository = (fetch: $Fetch) => ({ async get(cursor: null | string = null): Promise { let url = '/events/'; if (cursor) { url += `?cursor=${cursor}` } return fetch(url) }, })
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
Thank you! I'd go with useAsyncData as shown in kzbin.info/www/bejne/oImraYeoYsqrnqs 😊
@vensonhunt
@vensonhunt 6 ай бұрын
if the url is build upon query, which is not the options of useFetch, how to make it work
@TheAlexLichter
@TheAlexLichter 5 ай бұрын
How do you mean that? You can pass it to useFetch anyway ☺️
@mr.developer617
@mr.developer617 4 ай бұрын
Thank You
@TheAlexLichter
@TheAlexLichter 4 ай бұрын
You're welcome 👌
@elviskemboi7668
@elviskemboi7668 7 ай бұрын
am trying to use fetch with a laravelapi and when i run my nuxt app i get that useFetch component has already been mounted see the $fetch what can i do about this
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
My video about useFetch should help you there! kzbin.info/www/bejne/pJvWeImjmLypn7s 🙌
@yoskokleng3658
@yoskokleng3658 11 күн бұрын
so headache, i would use axios instead :)).
@TheAlexLichter
@TheAlexLichter 11 күн бұрын
Keep in mind that axios is comparable to $fetch but not to the fetching composables like useFetch or useAsyncData
@nanaassumadu4997
@nanaassumadu4997 7 ай бұрын
ow God I love you
@TheAlexLichter
@TheAlexLichter 6 ай бұрын
🙏🏻🙏🏻🙏🏻
@jurarexx
@jurarexx 7 ай бұрын
@TheAlexLichter
@TheAlexLichter 7 ай бұрын
Because it is checked (up to) 3x in the code 😊 Does that cause an issue? I briefly talked about that in kzbin.info/www/bejne/iqacg2Ntad-DsJI too 🙌
😲 An environment-aware Nuxt Configuration
10:09
Alexander Lichter
Рет қаралды 7 М.
The Biggest Issues I've Faced Web Scraping (and how to fix them)
15:03
Officer Rabbit is so bad. He made Luffy deaf. #funny #supersiblings #comedy
00:18
Funny superhero siblings
Рет қаралды 16 МЛН
哈哈大家为了进去也是想尽办法!#火影忍者 #佐助 #家庭
00:33
Worst flight ever
00:55
Adam W
Рет қаралды 38 МЛН
You're Probably Using Nuxt Wrong
5:16
LearnVue
Рет қаралды 26 М.
Organize your Composition API code (2k subscriber special)
18:22
Alexander Lichter
Рет қаралды 23 М.
Why use Type and not Interface in TypeScript
14:12
ByteGrad
Рет қаралды 208 М.
Laravel vs Rails for Javascript developers
19:50
Sam Lewis
Рет қаралды 4 М.
The BEST way to proxy your API in Nuxt
21:12
Alexander Lichter
Рет қаралды 17 М.
React Native vs Flutter - Which should you use?
22:31
Simon Grimm
Рет қаралды 35 М.
What is BFF?! (With Nuxt, Nitro and h3)
26:05
Alexander Lichter
Рет қаралды 7 М.
Run ALL Your AI Locally in Minutes (LLMs, RAG, and more)
20:19
Cole Medin
Рет қаралды 125 М.
The Pattern You MUST Learn in .NET
20:48
Nick Chapsas
Рет қаралды 88 М.