API Tutorial - Fetch Data with Axios - (Example in React)

Поділитися
Вставка
  • Опубліковано 8 вер 2024
  • Tutorial on how to make API calls to fetch data using axios. I'm using React in this example, but you'll know how to use axios anywhere 👍.
    Hope it helps!
    Feel free to say hi 👋:
    twitter: / techcheck__
    blog: dev.to/techcheck
    IG: / techcheck__
    Thanks for watching!
    -Andrew
    ❤️ Buy me a coffee/say thanks/support the channel ❤️: www.buymeacoff...
    Affiliate links to some of my gear 🤘🙏❤️
    (Best quality for the best price from my research)
    Awesome Accent Lights 😎: amzn.to/3UCaHvO
    Maono Microphone: amzn.to/3SxAVN6
    Logitech Webcam: amzn.to/3OyIORm
    Rival Mouse: amzn.to/3OwYFzG
    Wrist Pads: amzn.to/4bplhfn

КОМЕНТАРІ • 142

  • @christianyepez3425
    @christianyepez3425 Рік тому +38

    It's 3:38am this is the only striaght to the ponit video I found. I can finally get some sleep. Thank you for your work .

  • @KazmaAttack
    @KazmaAttack 2 роки тому +42

    you're a lifesaver man. it's such a pain in the ass finding a simple, straight to the point video. this is exactly what i needed, thank you

    • @techcheck3042
      @techcheck3042  2 роки тому +1

      Got you! I'm very glad to hear that. Thank you for watching and for the awesome comment

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

    Not gonna lie i probably watched thousands of tutorials on different subjects, and this one might be the coolest

  • @prabhurao2773
    @prabhurao2773 2 роки тому +6

    dude you made my day , " i have been falling for 24 hrs { thor : ragnarok loki reference } " with the same level of his frustration {loki} , cause i haven't been able to understand async await , fetch , try , catch , and the axios, i don't understand why there are so many ways man .... dammm these past 7 minutes are by far the most important 7 minutes in my entire 1 month of trying to understand api journey so far, all the big youtubers teach for super advanced devs but none of them know that 90 percent of their fan base are new / junior devs who are starting off and there is so much data out there that things might get overloaded that we end up not learning a very important skill. thanks mate. you have a new sub !!

    • @techcheck3042
      @techcheck3042  2 роки тому +1

      Wow that's so incredible to hear and totally made my day! That also makes me feel very inspired to make more videos. Next few are dedicated to you my friend! So glad I could help! And funny reference 😂😂

  • @anas980
    @anas980 2 місяці тому +1

    Great video! very well explained and I like the example with the button, it makes it easier to understand for beginners like me

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

      Love to hear that! Glad it helped and happy coding!

  • @SonnyTechAcademy
    @SonnyTechAcademy Рік тому +4

    well explained. Thank you! Much love from Ghana

  • @Samuel54-Diriba
    @Samuel54-Diriba 9 місяців тому +1

    I am from Africa , Ethiopia. Bro i'm so proud to you! you're very amazing for me in all of your tutorial videos. I had started this tutorial 1-15 parts & now i finished it. GOD bless you
    & also i will be your members !!! keep it up wow.

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

    "pretty much the most inspirational thing I've ever heard in my life" 🤣 great video man 🙏

  • @adhdmc
    @adhdmc 11 місяців тому +1

    You, are a god send. Seriously thank you so much for this.

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

      Hahaha my pleasure! Glad it helped!

  • @arietalzah5842
    @arietalzah5842 5 місяців тому +2

    Damn everything I needed in tenminutes with no bull! Subscribed!

  • @ayushs6812
    @ayushs6812 2 місяці тому +1

    quick and easy. thanks

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

      Glad it helped! Thanks for watching 🙂

  • @Usman._
    @Usman._ 9 місяців тому +1

    Need more content. This Chanel is good. Thanks for straight forward stuff.

  • @benjaminjvredevelt
    @benjaminjvredevelt 2 роки тому +2

    thats deep && pretty much the most inspirational thing i've ever heard in my entire life

  • @arsh2544
    @arsh2544 Місяць тому +1

    its 2AM in the morning, I was thinking to go sleep. But then I read the final quote "Once you choose hope, anything's possible"

  • @CodeWithBehram7497
    @CodeWithBehram7497 5 місяців тому +1

    To the point loved ur content

  • @Lifeofrandomness
    @Lifeofrandomness 11 місяців тому +2

    It's awesome. Straight to the point. Thanks man!👍

  • @SuicideDog
    @SuicideDog 6 місяців тому +1

    That cracked me up. "That's deep". Thx for a terrific vid

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

      🤣🤣 My pleasure and thanks for watching! Appreciate the comment 🙏

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

    Such a simple and on point explanation of the topic.Great work.

  • @Electro_69
    @Electro_69 3 місяці тому +2

    Best video in the world😁

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

    Thank you so much. this helkoped me a lot

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

      Awesome to hear! Thanks for watching and thanks for the comment!

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

    Excellent straight to the point video

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

    Heyo best Axios tutorial hands down in a short time.. thanks man🖤🖤🙌🏾

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

      Wow, thank you so much! ❤️❤️ Glad it helped! 🎉

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

    This is so detailed and clear and succinct.

  • @kunalbiswas372
    @kunalbiswas372 2 роки тому +3

    to the point and simple...thanks a lot

    • @techcheck3042
      @techcheck3042  2 роки тому +1

      Thanks for the compliment and thank you for watching

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

    Nice one. Top G 🔥

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

    Good, simple, understable thank you bro.

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

    Amazing straight to the point video. Thanks.

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

    that was pretty simple and funny as well

  • @jenkov2155
    @jenkov2155 10 місяців тому +1

    As everybody said, excellent tutorial.

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

    Straight to the point, I’ll buy you a Lamborghini one day

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

      Haha hell yeah! Looking forward to it, thanks!

  • @Mullai333
    @Mullai333 6 місяців тому +1

    Dude, your content is precise 🔥
    For ur work - Subscribed 🔔

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

      Thank you so much! Glad you like!

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

    thanks Andrew

  • @brett3554
    @brett3554 2 роки тому +5

    amazing tutorial, clear and no in your face bs.

  • @viniciusmantovani8619
    @viniciusmantovani8619 2 роки тому +1

    You are awesome.... I needed this for a project and you helped a lot. I just need to find out how to resolve CORS policy on my api right now 😅

    • @techcheck3042
      @techcheck3042  2 роки тому

      Thanks! CORS policies are always such a pain 😂😭

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

    This helped me a ton! Thanks so much.

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

    Thanks for this

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

    Very nice lesson. Thanks for sharing.

  • @mikey-dubs
    @mikey-dubs 7 місяців тому +1

    This was deep.
    Thank you

  • @HayrullaRuzimov
    @HayrullaRuzimov 14 днів тому +1

    Alhamdulillah that worked for me!

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

    🤣Love your appreciation of the "deep" quotes... 🤣

  • @justme364
    @justme364 2 роки тому +2

    Solid tutorial man good job!

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

    While watching this video, I was just smiling 😁. Thank you. BTW, I'm also subscribing now!

  • @amatajmartins1493
    @amatajmartins1493 8 місяців тому +1

    Too good I have to Subscribe 👍

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

    Great video

  • @CharlieDEVGT
    @CharlieDEVGT 5 місяців тому +1

    thank you for the video !! one question, how could i make a list of quotes from this example ?? i mean how to store each call to store in an array (let's say 7 random quotes instead of 1)

    • @techcheck3042
      @techcheck3042  5 місяців тому +1

      Thanks for watching! I just looked at the API documentation - it looks like you can send a GET request to the same url, but /quotes instead of /random - that will give you an array of quotes.
      docs.quotable.io/docs/api/b8b96bc546285-get-quotes-with-author-details

  • @MidhunSandhya
    @MidhunSandhya 11 місяців тому +1

    wow❤. Strating to the point. Thanks a lot.❤

  • @sehjotsinghguram.1801
    @sehjotsinghguram.1801 Місяць тому +1

    somebody give the sloppiest head to this man for making this. absolutely fucking awesome.

    • @techcheck3042
      @techcheck3042  Місяць тому

      @@sehjotsinghguram.1801 😂😂🎉🎉

  • @camilotello3296
    @camilotello3296 5 місяців тому

    Thank you very much :)

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

    Such inspirational content!

  • @ahmedpatel408
    @ahmedpatel408 2 роки тому +1

    great tutorial

  • @successezeh2009
    @successezeh2009 2 роки тому +1

    Very educative and inspiring tutorial.👏👏

  • @kacper-bm5ur
    @kacper-bm5ur Рік тому +1

    Dude i love you

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

      Hahaha. Love you too!

    • @kacper-bm5ur
      @kacper-bm5ur Рік тому

      @@techcheck3042 staying for longer for sure, i learned this in 7 minutes and i couldn’t understand it for a week hahah

  • @mamadikaba8516
    @mamadikaba8516 2 роки тому +1

    Thank a lot !

  • @neoarya4919
    @neoarya4919 2 роки тому +1

    That's feel easy peasy 😌

  • @suprabhatkumar5478
    @suprabhatkumar5478 2 роки тому +2

    its deep😂😂.. btw video was helpful..

    • @techcheck3042
      @techcheck3042  2 роки тому +1

      🤣🤣. Glad to hear it!

    • @suprabhatkumar5478
      @suprabhatkumar5478 2 роки тому +1

      @@techcheck3042 wish you make complete hooks tutorials like this masterpiece 😅😇

    • @techcheck3042
      @techcheck3042  2 роки тому +1

      @@suprabhatkumar5478 thanks so much! I have a video for all of the common hooks and a custom hook: useFetch 👍🍻

  • @freeyourmind7538
    @freeyourmind7538 5 місяців тому +1

    Whats the difference between axios and JS fetch?
    The only difference i can see is fetch word changed to axios, am i missing something here?

    • @techcheck3042
      @techcheck3042  5 місяців тому

      Axios is just easier to work with and has a lot of nice built-in behaviour like throwing errors on 400 and 500 response codes and auto-parsing JSON; you have to implement this yourself with fetch.
      Axios allows you to easily create dedicated HTTP clients with headers, a partial URL, etc built in so you don't have to supply them every time; you'd have to implement this yourself with fetch. This is very useful if your application needs to talk to multiple APIs.

    • @freeyourmind7538
      @freeyourmind7538 5 місяців тому

      @@techcheck3042 thanks for the response, axios seems like a winner amongst many, it seems like i need to add it to my arsenal.
      Will defo look into implementing it my learning

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

    Can you explain the difference between axios and fetch?

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

      They're basically the same thing with different syntax. Axios is a package that you have to install, but fetch is native to the browser so you don't have to install anything. But axios is easy to install, it's a small installation so it won't hurt, it comes with some extra features (which you typically don't have to worry about), and mainly - it's just easier to work with than fetch. Most web developers prefer to use axios 👍

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

    Thnks a lot , its a great tutorial man ! Can you share the source code ?

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

      Thank you! And sure! Once I’m back at my laptop

  • @Achilleas_1996
    @Achilleas_1996 Місяць тому +1

    im trying to make a weather app , and its my first time trying to fetch an api , the guy in the video uses an .env file , what is its use

    • @techcheck3042
      @techcheck3042  Місяць тому

      The .env file is for placing environment variables. Those are variables used for sensitive data (like API keys) that you might not want to show publicly. So it'd show the environment variable instead.
      I have a video on how to set those up here: ua-cam.com/video/-oJ3sAthWg4/v-deo.html
      and actually a video on how to use a weather api here: ua-cam.com/video/S_py2rXNizo/v-deo.html
      Happy coding!

    • @Achilleas_1996
      @Achilleas_1996 Місяць тому

      @@techcheck3042 thanks a ton. I'll go watch them now

  • @ogazboiz
    @ogazboiz 2 місяці тому +1

    Why don't you use res.json

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

      Axios takes care of that for us! 🎉

  • @thehuseein
    @thehuseein 2 роки тому +1

    clear as fuck, loved your ending song

    • @techcheck3042
      @techcheck3042  2 роки тому

      Thank you! Marvel Years - Check The Vibe 🤙

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

    i am getting an error
    TypeError: axios__WEBPACK_IMPORTED_MODULE_2__.default.get(...).this is not a function

  • @yugeshkk3062
    @yugeshkk3062 2 роки тому +1

    how to get the array values from json.

    • @techcheck3042
      @techcheck3042  2 роки тому

      const array = [1, 2, 3].
      Inside your render function you'd open a bracket to write JavaScript and map over the array. For each return of each item, you'd return html and other brackets for each data item from the array.
      { array.map(num => (
      {num}
      ) }

    • @yugeshkk3062
      @yugeshkk3062 2 роки тому +1

      @@techcheck3042 Thanks man

  • @farashafarasha5833
    @farashafarasha5833 8 місяців тому +1

    What about api key?

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

      Not all APIs need an API key, but you would typically save that to an environment variable and use the env variable when/where needed.
      I’m going to make some more videos for different APIs. I’ll cover API keys on one that needs it! Likely the Google Maps API 👀

    • @farashafarasha5833
      @farashafarasha5833 8 місяців тому +1

      @@techcheck3042 thank you

  • @sxuwrr
    @sxuwrr 4 місяці тому +1

    "is deep" 💀

  • @AdnanKhan-yg4ng
    @AdnanKhan-yg4ng Рік тому +1

    thx nigga