Using Async/Await with the Fetch API - JavaScript Tutorial

Поделиться
HTML-код
  • Опубликовано: 3 дек 2024

Комментарии • 62

  • @Pareshbpatel
    @Pareshbpatel 2 года назад +1

    Very clear tutorial on the use of Async/Await with FetchApi. Thanks, Dom
    {2021-12-28}, {2022-10-20}, {2023-08-24}

  • @ChuanyiXia
    @ChuanyiXia 11 часов назад

    この動画で長い間悩んでいた問題が解決できました。コードがすっきりして、とても気に入っています。複雑で長い`then`ステートメントによるエラーに疲れていたので、本当に助かりました!

  • @marwanbassam9932
    @marwanbassam9932 3 года назад +10

    Wow. I was stuck on something for hours and this video just cleared up everything for me. Very simple and straightforward with easy to understand examples, great video!

  • @OverwhelmingGrace
    @OverwhelmingGrace Год назад

    This video really cleared up problems I've been struggling with for a long time. I love how it cleans up my code. I am so tired of errors caused by long, complicated, multiple 'then' statements.

  • @HenrryWith2Rs
    @HenrryWith2Rs 2 года назад

    Stuck for 2 days and your video just solved it in 7 minutes. thank you so much.

  • @julianaamerico3722
    @julianaamerico3722 3 года назад +1

    That's the best video on the subject I've seen so far!

  • @XerosXIII
    @XerosXIII 4 года назад +1

    holy smokes, wish I gotten to this video years ago! so clear and concise! very nice!

  • @andrzejserafin2758
    @andrzejserafin2758 3 года назад

    that's what I wanted, no bullshit just straight up quality content.

  • @hyfydistro
    @hyfydistro 3 года назад +3

    That one-line async / await function blew my mind away.

    • @jimmymarcel6784
      @jimmymarcel6784 3 года назад

      you probably dont care but if you are bored like me during the covid times then you can stream all the new movies on InstaFlixxer. Been streaming with my brother for the last few weeks :)

    • @bodenarjun6557
      @bodenarjun6557 3 года назад

      @Jimmy Marcel yup, been using instaflixxer for since december myself :D

  • @MagnusGoGo
    @MagnusGoGo 2 года назад

    This was incredibly helpful! Thank you so much. I didn't realize that .json() requires an await as well, and I was pulling my hair out trying to figure out why I was getting a promise object instead of the data after using response.json(). Thanks again!

  • @armanrivard5848
    @armanrivard5848 Год назад

    Also saved me quite a bit of time. Thank you !

  • @AleksandarIvanov69
    @AleksandarIvanov69 4 года назад +8

    Got some interviews coming, wish me luck!

  • @flexDevelop
    @flexDevelop 4 года назад +2

    As always, clean code, really easy to understand!
    Content idea: What about headless browser tutorial (with something like puppeteer)?
    Keep up with the great work!

    • @dcode-software
      @dcode-software  4 года назад

      Cheers mate! And thank you for the suggestion ☺️

  • @ad7465
    @ad7465 2 года назад

    You just made my day, huge thanks !

  • @magneticartist
    @magneticartist 3 года назад +1

    Thank you! Great explanation. Makes code so clean and efficient.

  • @Hugos68
    @Hugos68 2 года назад

    This video helped me fix this problem i was stuck on, thank you

  • @fahrul3387
    @fahrul3387 Год назад

    thankyuso muachh this content truly help me figure out my project prblem

  • @thebassgallery9338
    @thebassgallery9338 Год назад

    You’re awesome man thank you

  • @lejonjaro7695
    @lejonjaro7695 3 года назад

    Clean explanation and makes it easy to do. Thanks

  • @montazmeahii6029
    @montazmeahii6029 3 года назад +1

    at 2:28 it's not really fair to say the await is 1 line while the fetch dot then is 3 lines because the await also requires the async function

  • @brainsnackstore
    @brainsnackstore 3 года назад

    Simple and to the point noice

  • @diwakarsingh4579
    @diwakarsingh4579 3 года назад

    THanks it worked like charm

  • @andrewcekuta8627
    @andrewcekuta8627 Год назад

    great video, thanks

  • @bmac-cz6rk
    @bmac-cz6rk 3 года назад

    Awesome explanation, thank you so much!

  • @rangabharath4253
    @rangabharath4253 4 года назад

    Awesome as always

  • @sabuein
    @sabuein Год назад

    Thank you.

  • @albertoroberto595
    @albertoroberto595 3 года назад

    Gracias, excelente explicación.

  • @piotrszczesniak
    @piotrszczesniak 2 года назад

    Thanks for the video. I'm quite familiar with GET method, and wonder if we need to use async/await for other methods too?

  • @alimedani0296
    @alimedani0296 4 года назад +1

    Thank you sir!

  • @nathaliealmstrom4082
    @nathaliealmstrom4082 2 года назад

    Great video! it truly helps! just one question. in the console you can see the fetched values, but in the end theres a text __proto__: Array (0) ...My qestion is, how does this affect the next code, that uses the data from the API?
    I am atm stuck with a code were I have this exact output, but the functions that requires the data from the API don't work.. I am just trying to check my error from all angles here. Many thanks!

  • @oah8465
    @oah8465 3 года назад +1

    Hi
    fantastic video but this will turn ur code to synchronous code, i.e., the code will block until the fetch completes and the code returns from the "await" which defeats the whole purpose of having promises. From clean-code perspective your code is elegant but from practicality point of view, the above code will have ur HTML document freeze and become un-responsive till the await returns.
    Your code will be much more useful if you use that async function inside the first "then".
    Just to be clear, your code will force the JS code to be executed in the main thread (the one that handles the page events which should never be frozen/blocked). Throwing "await" in the main JS thread, forces ur code to wait for the function to return i.e., the entire page will block until the function returns. Assume the async function takes 30 seconds to return, now the page is un-responsive for 30 seconds.
    citing the documentation from MDN:
    " can be put in front of any async promise-based
    function to pause your code on that line until the promise fulfills,
    then return the resulting value."

  • @nolose6542
    @nolose6542 3 года назад

    If I type with arroz function is a same ?

  • @rt-uh6mt
    @rt-uh6mt 3 года назад

    This is a good tutorial but what if I don't want to fetch onload? I want to do a fetch after a button is clicked. How do you add an eventlistener to that?

  • @lycanunleashed
    @lycanunleashed 2 года назад

    i dont know if you check your messages or not but there is something i have been stuck on from some time now and require some assistance about so please help me.. suppose we fetched an array of data using fetch api once and want to use the data in 10 different functions.i declare the array data on the top and then fetch data into it.. after that i try to use that data into other functions but the fetched data is not available in other functions..so i ask how can i do so without making each and every function async..

  • @BenHuxford
    @BenHuxford Год назад

    I'm not sure why the document.addEventListener stuff is needed. Can anyone explain please?

  • @トゥアンファム
    @トゥアンファム 3 года назад

    what is theme name of vs code?

  • @BillBrutzman
    @BillBrutzman 3 года назад

    How about using unique variable names _ rather than overLoading the variable "users"?

  • @yashdesai8372
    @yashdesai8372 3 года назад

    Can you make a video on making put, post, delete requests using fetch api?

    • @dcode-software
      @dcode-software  3 года назад +1

      I've got videos on using POST with Fetch, but will consider the others 🙂 thanks

  • @flashback8504
    @flashback8504 2 года назад

    what is theme? tell me please)

    • @dcode-software
      @dcode-software  2 года назад

      It's my theme, called "dcode"

    • @flashback8504
      @flashback8504 2 года назад

      @@dcode-software oh , thanks , you're theme very cool! I like it

  • @amircahyadi9219
    @amircahyadi9219 2 года назад

    2022 🤟

  • @NehaKumari-s14
    @NehaKumari-s14 2 года назад

    Code is not looking clear

  • @Kevin-hj8hl
    @Kevin-hj8hl 3 года назад

    ur guide is good but no one show a way to charge large data, u only show how charge 2 records and it dont work at real world