Combining Async Await with Promises

Поділитися
Вставка
  • Опубліковано 15 вер 2024
  • Async and await can be combined and used with Promises but the results may sometimes be surprising.
    This video looks at how you can effectively combine Async, await, and Promises.
    It is important to remember that fetch( ) calls are also Promises.
    Code GIST: gist.github.co...

КОМЕНТАРІ • 16

  • @bhavarkumavat3202
    @bhavarkumavat3202 4 роки тому +3

    Simple & Clean === Quality === True (I speak JS 😇🤐) , Distributing knowledge is one of the best gifts and thing one can do. Thank You for teaching me these concepts

  • @rotrose7531
    @rotrose7531 4 роки тому +1

    Thank you for another wonderful lesson. Many teacher just make this kind thing like a format, you are the first to explain what is happening inside and where the error comes from. Simply great.

  • @sidarjunful
    @sidarjunful 3 роки тому

    Thanks for taking the time and making this awesome content, and making javascript wonderful to understand.

  • @chesterxp508
    @chesterxp508 3 роки тому

    Another very cool tutorial!

  • @jaehyeokchoe6919
    @jaehyeokchoe6919 6 років тому +1

    Thank you for helpful contents! Someday please make a video introducing your development environment for the beginners :)

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  6 років тому

      I make my videos using Brackets with the Emmets plugin. I have videos on both already. I demo most things in either Chrome or in the Terminal (Command Prompt). For things that require a web server, I use MAMP. I have a number of videos about aspects of MAMP too. Just do a search on my channel home page for "Brackets" and "Emmet" to start.

  • @bobobo1673
    @bobobo1673 3 роки тому

    Interesting! Now I try to see how use asyn await and promise all together

  • @radoslavtsanev6822
    @radoslavtsanev6822 4 роки тому

    So the main difference with regular Promise is that here we get the value of the promise and we don't need to use then?
    Also if I remove async and await and reject the promise in the delay function, when I log the Promise I get [[PromiseStatus]]: "resolved" - isn't that supposed to be rejected? Thank you

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  4 роки тому +1

      Effectively yes, we are removing the requirement for the then( ) by adding await.
      At 3:15 in the video you can see the delay function run without the await and it will contain Promise pending. ~1000ms later it will show rejected.

    • @radoslavtsanev6822
      @radoslavtsanev6822 4 роки тому +1

      @@SteveGriffith-Prof3ssorSt3v3 Ok, I got it correctly. Thank you for your response!

  • @ironmanlifts
    @ironmanlifts 4 роки тому

    Thanks great videos.

  • @parthkumarchaudhary
    @parthkumarchaudhary 4 роки тому

    Very Informative and great detailed oriented videos.
    can you suggest best resources to learn JS ?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  4 роки тому +2

      There are lots of great resources online. On UA-cam Wes Bos, Brad Traversy, and Colt Steele are all really good.

  • @ВолодимирДжичко
    @ВолодимирДжичко 6 місяців тому

  • @rishabhs
    @rishabhs 5 років тому

    why resolved promise has printed 42 at the end of the video? We passed ms as 1000 right?

    • @SteveGriffith-Prof3ssorSt3v3
      @SteveGriffith-Prof3ssorSt3v3  5 років тому

      1000ms is the delay before the function resolve gets called. 42 is the value passed to the function resolve.