Next.js 13 Crash Course Tutorial #6 - Fetching & Revalidating Data

Поділитися
Вставка
  • Опубліковано 20 сер 2024
  • In this Next 13 tutorial series, you'll learn the basics of Next.js to make a simple project, using the new app router & server components.
    🚀🥷🏼Access the entire Next.js 13 Masterclass course on Net Ninja Pro:
    netninja.dev/p...
    ➡️ Use promo code NEXTNINJA50 for 50% off!
    📂🥷🏼 Access the course files on GitHub:
    github.com/iam...
    📂🥷🏼 CSS File from course files:
    github.com/iam...
    💻🥷🏼 React Tutorial:
    netninja.dev/p...
    🔗🥷🏼 Next.js docs - nextjs.org/docs
    🔗🥷🏼 CSS modules in Next.js - nextjs.org/doc...
    🔗🥷🏼 VS Code - code.visualstu...

КОМЕНТАРІ • 69

  • @justydev
    @justydev Рік тому +8

    Add this to "scripts" in your package.json
    "server": "json-server --watch --port 4000 ./_data/db.json",
    and then you can run `npm run server` to make it easier to restart the json-server without having to remember the command

    • @nwtdbssb
      @nwtdbssb 10 місяців тому

      good!

    • @michimaru9023
      @michimaru9023 7 місяців тому

      i got an error and it says "ps1 cannot be loaded because running scripts is disabled on this system." and when i add that in my script, it work perfectly, how does it occur?

  • @456jkl1
    @456jkl1 8 місяців тому

    Im very happy I have finally found a really good youtuber who does the tutorial videos for the beginners like me. Please keep posting. I have subscribed

  • @iancarr3923
    @iancarr3923 9 місяців тому

    An excellent "companion" to the "official" next.js tutorial.

  • @velmar.wolfdream
    @velmar.wolfdream 11 місяців тому +5

    I received the "json-server : The term 'json-server' is not recognized as the name of a cmdlet,
    function, script file, or operable program." error, but I've managed to solve it.
    So if anyone runs into this issue in the future, just add "npx" in front of "json-server" in the terminal

  • @acodersjourney
    @acodersjourney 10 місяців тому +4

    I'm grateful for your content. Keep inspiring us!

    • @NetNinja
      @NetNinja  9 місяців тому +1

      Thanks! I appreciate that! :)

  • @randycullins4136
    @randycullins4136 Рік тому

    I love the Zelda references in the ticket body lol

  • @rnavedojr
    @rnavedojr 4 місяці тому

    That is fine and it works locally but I have an issue using a dynamic baseUrl when building for some reason.

  • @owenwexler7214
    @owenwexler7214 9 місяців тому

    The way caching works is the one thing I don't like the most about app router so far. Caching should always be opt-in, never opt-out. That's a major footgun if you ask me. But thank you for the info on revalidating. App router seems to be looking good other than this so far.

  • @kecoje
    @kecoje Рік тому

    Thank you - looking forward to the next part

  • @ZeyadMohamed-xs9ew
    @ZeyadMohamed-xs9ew Рік тому +2

    Is there a way to revalidate with axios?

  • @abhisheksah1867
    @abhisheksah1867 2 місяці тому

    should have used next route/API for serving data ?

  • @josephmgift
    @josephmgift Рік тому +1

    Thank you for this.

  • @ashonshakya
    @ashonshakya Рік тому +2

    revalidate is not working for me, it fetches new data everytime

  • @valerio9851
    @valerio9851 7 місяців тому

    your videos are helping me a lot

  • @WanKy182
    @WanKy182 9 місяців тому

    Got problems with caching and revalidation, after some troubleshooting i figured out that in my network tab disable cache was enabled)

  • @RitikRaj-we2sc
    @RitikRaj-we2sc Місяць тому

    Hey, I am not using fetch in mmy server compoennt instead I am calling a function which verify the cookie and return decoded data. And this data is what I display in the page.
    Now, how to revalidate this ?
    Currently, even though from client component I do router.push("/"), it still shows me the old state "User not logged in". Only after I manually go to that "/" page that I am shown the updated data.
    Please help me out here.

  • @user-ze8tz9no8l
    @user-ze8tz9no8l 7 місяців тому

    Even after 30 seconds Next was still serving up the cached data even though i refreshed more than once however after reading a comment about the disable cached setting in the Network tab being enabled i opened it up and disable it and then refreshed and then it worked - i could only see two tickets so if your still seeing the cached data like i was after 30 seconds even after refreshing multiple times - open the Network tab and disabled your cache
    Awesome tutorial as always !! 🥷

  • @user-vw1lp4px6m
    @user-vw1lp4px6m Рік тому +1

    in some cases (fetch) failed when i'm using in SSR ,but in client side rendering. it works fine ,i'm fetching some images from api

  • @ZenchantLive
    @ZenchantLive Рік тому +2

    Could you please add a NextAuth v4, and 0auth tutorial to your Next 13 Course? That's the only thing it is missing for me to fully understand how to complete my project. You are a great teacher!!

    • @NetNinja
      @NetNinja  Рік тому +1

      Hi Jay, thanks for your comment :) you can find the Next 13 Masterclass on the Net Ninja pro site. It goes much deeper than the crash course: netninja.dev/p/next-13-masterclass thanks again!

    • @ZenchantLive
      @ZenchantLive Рік тому +3

      @@NetNinja I saw that! I will be getting it. But I need to know, does it cover authentication? That is what u need ti know now.

    • @jakubgodlewski2506
      @jakubgodlewski2506 11 місяців тому

      it does, just open the link he sent you and go through the curriculum. You will see entire section on authentication.@@ZenchantLive

    • @davidrowlands8548
      @davidrowlands8548 11 місяців тому

      @@ZenchantLive I think it uses supabase log in system.

  • @Mark-lg2qe
    @Mark-lg2qe 9 місяців тому +1

    Can I use axios?

  • @justreddit2074
    @justreddit2074 6 місяців тому

    keep it up you awesome MAAN!

  • @rodrigopolanco8434
    @rodrigopolanco8434 9 місяців тому +3

    If you're fetching data as responses from the openAI API and want to keep an open request from the frontend (nextjs) to the backend (django), is it possible to do it like in broadcasting or streaming? Do you know what is the most common and efficient case? Thanks and cheers!

  • @user-ew9ep3pp2j
    @user-ew9ep3pp2j 6 місяців тому

    Thanks for this video.

  • @programmingwithnit5308
    @programmingwithnit5308 Рік тому

    Thank brother your explanation is very good

  • @cmlra
    @cmlra 6 місяців тому

    could you please guide me which one is better to ues, functional compnents or arrow components in react

  • @sulemanmughal5397
    @sulemanmughal5397 8 місяців тому

    i come to watch net ninja just for his "whoohoo" when he show his code on his repo XD jajaja

  • @me29_hi8
    @me29_hi8 4 місяці тому

    so the data is updated only after refreshing the page?

  • @EduCodigosPro
    @EduCodigosPro 6 місяців тому

    We can use "async" in function TicketList because it's a Server Component, right? because we cannot create Async Client Components.

  • @moe9647
    @moe9647 10 місяців тому

    how do i revalidate data if im using something like appwrite sdk? all my data is cached and it doesn't refetch

  • @everyday_mary
    @everyday_mary Рік тому +2

    I just bought the complete course! Is there a way to get the transcripts for the videos on the course site (I use transcripts a lot on UA-cam when studying, e.g. for searching, and it also makes it easier for me to follow along since English is not my native language)? Thank you very much in advance!!

  • @raminjamal
    @raminjamal Рік тому +1

    What font are you using bro in vscode could you share it ?

  • @user-lz2wf5dz2f
    @user-lz2wf5dz2f 2 місяці тому

    tickets not showing.

  • @AntNZ
    @AntNZ 8 місяців тому

    Whats the best way to import the json data from a file using node?

  • @z1982_
    @z1982_ 9 місяців тому

    Great video!
    At 11:30 you are explaining how to benefit from the extension of the fetch API.
    How can I benefit from it too if I use a function that is stored in another « services » folder?

  • @alexg7282
    @alexg7282 Рік тому

    Thx

  • @user-jq6vg4mo2z
    @user-jq6vg4mo2z 8 місяців тому

    Hello, At first. Your larning seasons are great, I try to reproduce your example in TypeScript for improving my self learning. In the chapter 6 I have a problem. I prefer to use the arrow function syntax while coding. When I write the TicketList with arrow functions, there were no tickets fetched by the server. It will also not displayed the tickets.length === 0 case. Write the code like described in the course, it works. Is there a difference between the two syntax in Next JS (exept the this keyword)? My main seen difference in the arrow-code is the export default at the end of the TicketList.tsx. Thanks a lot for your help :)

  • @khalifaomani1242
    @khalifaomani1242 11 місяців тому

    lovely content ^_^ , so revalidate cashed in server right ? not user browser :)

  • @alinadorofeeva8903
    @alinadorofeeva8903 Рік тому +1

    I can't retrieve fetch data Unhandled Runtime Error
    Error: fetch failed

  • @VilliamLundin-bw2mg
    @VilliamLundin-bw2mg 11 місяців тому

    What extension do you use to get Tailwind autocomplete?

  • @brandonque2152
    @brandonque2152 Рік тому

    is tutorial # 7 available yet?

  • @rajahutan12134
    @rajahutan12134 Рік тому +1

    Does your course have English subtitles?

  • @stonehere339
    @stonehere339 Рік тому

    I think that by default all components are server components in version 13 and we can define them outside the app directory they don't have to be inside the app directory and they're still server components.
    Am I right?

    • @juanmosquella6173
      @juanmosquella6173 Рік тому

      i thought that just de components inside the app directoy are server components, but I may be wrong

  • @user-cf9uv7cd4n
    @user-cf9uv7cd4n 7 місяців тому

    thank you, I'm getting this error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.

  • @tomcrooks1627
    @tomcrooks1627 Рік тому +6

    Wrong thumbnail! 😊

    • @NetNinja
      @NetNinja  Рік тому +1

      Nice spot, sorted :)

  • @shawnlee5956
    @shawnlee5956 10 місяців тому

    the fetch api code here will cause the infinite loop on keep calling the api again and again every 2 sec.

    • @shawnlee5956
      @shawnlee5956 10 місяців тому

      self answer back my question.
      if put Sever Components with 'fetch' in to Client Component with fetch = will have infinite loop,
      the correct way is make the whole page Server Component, only the button etc as Client Components = will solve the infinite loop

  • @geniusmaker6438
    @geniusmaker6438 Рік тому

    So, what is the difference between cache: 'no-store' and revalidate: 0?

  • @jaroslavhuss7813
    @jaroslavhuss7813 10 місяців тому

    Puting a fetch function inside some component is imho absolute violation of BE architecture... I may be too sensitive, but this is insane...

  • @baibhavmundra5205
    @baibhavmundra5205 11 місяців тому

    I'm facing issues with caching. No matter what I set, Next.js is caching the entire page. I am outputting a Math.random() number on the page and even after multiple refreshes, the number does not change. What am I doing wrong?