How to Easily Call APIs With Fetch and Async/Await in JavaScript

Sdílet
Vložit
  • čas přidán 5. 09. 2024
  • In today's video I'll be showing you how easy it is to call APIs (REST) using the Fetch API in JavaScript and Async/Await.
    This is the way I typically call my APIs and provide authorization tokens or headers in the front-end (if appropriate).
    For your reference, check this out:
    developer.mozi...
    🏫 My Udemy Courses - www.udemy.com/...
    🎨 Download my VS Code theme - marketplace.vi...
    💜 Join my Discord Server - / discord
    🐦 Find me on Twitter - / dcodeyt
    💸 Support me on Patreon - / dcode
    📰 Follow me on DEV Community - dev.to/dcodeyt
    📹 Join this channel to get access to perks - / @dcode-software
    If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
    #dcode #javascript

Komentáře • 31

  • @abubalo
    @abubalo Před 2 lety +4

    What is more exciting than seeing Dcode new video notification.

  • @ernestoluckie
    @ernestoluckie Před 10 měsíci

    I really wanna say THANK YOU. This tutorial helped me solve a problem in which I was stuck for weeks!

  • @garmerbak
    @garmerbak Před rokem +2

    very nicely done, simple and clear.

  • @LD-oq1co
    @LD-oq1co Před 2 lety +1

    This video helped me a tone with working out how to build a feature. Thank you so much

  • @chriscalver8595
    @chriscalver8595 Před rokem

    Excellent video .....thank you

  • @muntasirhossen9730
    @muntasirhossen9730 Před 3 měsíci

    How is the job market now in Australia for software developers?

  • @viniciusm.m.7822
    @viniciusm.m.7822 Před 2 lety +1

    Thanks, man!
    Deus abençoe você!

  • @webdevuk
    @webdevuk Před 2 lety

    good video, mate, I'm going to try to use some of this to do basic authentication on an open power automate or gappsscript endpoint for my browser extension.

  • @justnow7263
    @justnow7263 Před 2 lety

    Wow, amazing.
    Sir, you are helpful

  • @dansmar_2414
    @dansmar_2414 Před 2 lety

    Great video, Thank you so much!

  • @bjornsurstrom4528
    @bjornsurstrom4528 Před rokem

    Thank you!

  • @alexandruteodor3585
    @alexandruteodor3585 Před 2 lety

    What color theme are you using in this video? I like it so much.

  • @LD-oq1co
    @LD-oq1co Před 2 lety

    can someone explain why you probably shouldn't use an onClick handler on the element?

    • @mharding7
      @mharding7 Před rokem

      @Joaquin Ocampo Why? Vue, React, Alpine JS and everyother JS framework call functions from inline. Why is it a bad idea?

  • @workrelated7632
    @workrelated7632 Před 2 lety

    Super ❤️

  • @tamas-pamas
    @tamas-pamas Před 2 lety

    Even if you get your API token from the database it'll be still visible in the dev tools if you have to send it through in the Headers. Am i wrong here?

    • @sc1ss0r1ng
      @sc1ss0r1ng Před 2 lety

      It might be, not sure.
      But when looking at fx. CZcams's info under Network in DevTools, I can see that my Authorization is a hashed key.
      So no matter what, it might just be a good idea to hash it when returning it from the database.

    • @tamas-pamas
      @tamas-pamas Před 2 lety

      @@sc1ss0r1ng if the API accepts it hashed then it's OK...

    • @dcode-software
      @dcode-software  Před 2 lety +1

      Sorry I should have made this clearer in the video. What I meant was that you let your back-end make the API call and then pass the result down to the front-end

  • @sammybammy52
    @sammybammy52 Před 2 lety

    dcode.js ✨

  • @umangternate
    @umangternate Před 2 lety

    Is it possible to request a tutorial? If yes, this is the story. So, I want to know how long a user is on a page. I know how to set an entry time var but I don't know how to set an exit time var and send the data to backend right before the user moves to other page. Please teach me how to do that. I tried to call a function with onbeforeunload but it didn't work for me.

  • @leonvanrijswijk8409
    @leonvanrijswijk8409 Před 2 lety

    Thanks, btw your udemy link does not work, 404

    • @dcode-software
      @dcode-software  Před 2 lety +1

      Hey thank you there are no courses on there at the moment but will be uploading some more later in the year!

  • @Pareshbpatel
    @Pareshbpatel Před rokem

    {2022-10-20}

  • @vishvish24
    @vishvish24 Před 2 lety

    I am getting an error in javascript when using for loop for assigning id dynamically. Can u guide? How to share u code ?? Ur mail id pls