AsyncData Hook v Fetch Hook in Nuxt

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 ม.ค. 2025

ความคิดเห็น • 30

  • @maskman4821
    @maskman4821 4 ปีที่แล้ว +6

    very clear demo and explanation, I always use asyncData and nuxtServerInit to render page in server side, and using vuex for component to get the data, but using fetch for dynamic fetching is also cool, just need to add a loading spinner or skeleton screen to make the waiting pleasant and enjoyable !!!

    • @DebbieOBrien
      @DebbieOBrien  4 ปีที่แล้ว +1

      thanks for the nice feedback as always Stephen

  • @Gainmackain1
    @Gainmackain1 4 ปีที่แล้ว +2

    Thanks for the videos, you're a life saver.

  • @j_hull
    @j_hull 4 ปีที่แล้ว +1

    So easy now - which I know I’ve read before - but sinks in with this video (thanks!) - asyncData for pages, fetch for components.
    In my app, I have a bunch of page that are the same regardless of guest/subscriber - I’ll use async for that. And then for those subscriber premium components that lay in all the goodness, I’ll use fetch for those...thanks!

    • @DebbieOBrien
      @DebbieOBrien  4 ปีที่แล้ว

      glad it was of help 🥰

  • @agun21st
    @agun21st 3 ปีที่แล้ว

    very nice explanation. you cleared my confusion Mam. Thanks a lot.

  • @arashkenji480
    @arashkenji480 2 ปีที่แล้ว +1

    love your voice

    • @DebbieOBrien
      @DebbieOBrien  2 ปีที่แล้ว

      why thank you :)

    • @arashkenji480
      @arashkenji480 2 ปีที่แล้ว

      @@DebbieOBrien it reminds me good things

  • @behzodjon
    @behzodjon 3 ปีที่แล้ว

    Great explanation!!!!! Want more!!!!!!!

    • @DebbieOBrien
      @DebbieOBrien  3 ปีที่แล้ว

      thanks, glad you liked it

  • @venkychowdary
    @venkychowdary 4 ปีที่แล้ว +1

    Tysm
    continue to make more content don't stop
    _/\_

    • @DebbieOBrien
      @DebbieOBrien  4 ปีที่แล้ว

      thanks I won't. But I lost my voice this week so you might have t wait til next week. However I did create this free course which got published yesterday - explorers.netlify.com/learn/get-started-with-nuxt

    • @venkychowdary
      @venkychowdary 4 ปีที่แล้ว +1

      @@DebbieOBrien recover fast💪💪💪

  • @rey6253
    @rey6253 3 ปีที่แล้ว

    Thanks a lot for this video, have been strugglinh 4 hrs yesterday to find a way how to redirect from fetch method, now seems I will have to stick to asyncData

  • @bogdan.c
    @bogdan.c 4 ปีที่แล้ว

    Thank you! 🙌🏻

  • @estuardoaguirre123
    @estuardoaguirre123 4 ปีที่แล้ว +1

    Hi! I have a question, which one is better, fetch anything I need on a page using asyncData method and pass all the information to the components via props (or using the vuex store) or delegate the fetch action (using fetch method) to the components and make them fetch the information that they need? I hope you understand me!
    Anyway, great videos!

    • @jllastrilla
      @jllastrilla 4 ปีที่แล้ว

      same here. following this one =)

    • @DebbieOBrien
      @DebbieOBrien  4 ปีที่แล้ว

      it depends on what you want. there is no right or wrong way. do you want the user to go to an error page if nothing returned - then use asyncData. do you have various api calls on a page such as blog posts and comments then fetch works better cause if comments api fails you can still see posts. or you can use asyncData to get posts from api and fetch to get the comments. hope that helps

  • @jendiamond90026
    @jendiamond90026 2 ปีที่แล้ว

    what is the rest of that line of code under your photo? const mountains = await $axios.$....

    • @DebbieOBrien
      @DebbieOBrien  2 ปีที่แล้ว

      not sure without watching it back but all demos can be found here - nuxtjs.org/examples/data-fetching/async-data

  • @shutterradio
    @shutterradio 4 ปีที่แล้ว

    This tutorials are awesome! I'd like to learn more about vue-apollo and graphql if it's something you want to do

    • @DebbieOBrien
      @DebbieOBrien  4 ปีที่แล้ว +1

      Coming soon! I promise. however if you are in a hurry I have some courses on vue school on it - vueschool.io/courses/vue-apollo-graphql-fundamentals
      vueschool.io/courses/learn-graphql-fundamentals

  • @aliguzel4688
    @aliguzel4688 3 ปีที่แล้ว

    could you share the sources? :)

    • @DebbieOBrien
      @DebbieOBrien  3 ปีที่แล้ว

      most of the content is from the nuxt docs examples
      nuxtjs.org/examples/data-fetching-async-data