How To Make An API Request in ReactJS With Axios and Fetch - Tutorial [2020]

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

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

  • @Scrany99
    @Scrany99 4 года назад +50

    You are an absolute legent. I've spent the whole day trying to figure out how to do it and this has been the best explained and the most complete explanation I've seen for React based in fuctions and not classes

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

      I have a further question. I have in one file called "fetchCall.js" a fetch call to an API, but I want in another file called "inputTextFilled.js", which is a form, I want to have some prefilled information for some of the parts of the form. How can I make it to be able to import the values from fetchCall.js to inputTextFilled.js?

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

      Thank you so much for the positive comment! I am glad I could help!

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

      You can make the api call from the fetchCall.js and return those by exporting them. Then just call the fetchCall inside the inputTextField and use the values returned.

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

      @@PedroTechnologies So, to do that I should declare the variable outside the function with a "export const[name,setName] = useState("")" and then in the inputTextField I should do an import {name} from './fetchCall'
      And then just to access the data what should I write? Does it work only writing "name"?

  • @prasanthraonilapu8809
    @prasanthraonilapu8809 4 года назад +34

    Nice pacing dude, you weren't speed piling information on us and you weren't slowly stretching things out either. I understood it quite well.

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

      Thank you! Glad you enjoyed it! I always get scared that I am going too fast or too slow hahaha

  • @arhamraza5019
    @arhamraza5019 2 года назад +3

    Oh god!!!!! after days of struggling for a single concept and getting to know that its this simple.
    Thanks man for this

  • @WorkshopMaybe
    @WorkshopMaybe 4 года назад +10

    Nice explanation in under 10 minutes, thank you!
    And your responses to the jokes had me cracking up, that could be its own youtube series ;)

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

    I watched few tutorials before . They are super fast and not explaining even in a simple details like you . Your videos is very clear . thhanks youuu

  • @lance740
    @lance740 Год назад +1

    Best video covering this that I have found. Thank you so much, most videos are overly complicated and 20 minutes long. This was so straight to the point and explained clearly

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

      Was it just me or chatGPT kept switching up the file structure everytime i needed more details for this?

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

      Exactly..well explained and straight to the point.

    • @owofrostyy8840
      @owofrostyy8840 11 месяцев назад

      ​@@Shaojeemyit's not ChatGpt it's just he has an extension specifically for React installed in his IDE. All it does is give him hints and fix his React code when needed

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

    Great video. It was direct to the point with all the info needed none of the info we didn't want!

  • @knotcircle2844
    @knotcircle2844 4 года назад +4

    I heard about this Axios from your previous video of ReactJS MySql tutorial. Really helpful for beginners like me on reactjs and axios. Thank you

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

      I am glad you liked it! When I first tried to learn fetch I thought it was weird, when I saw axios it made so much more sense!

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

    Thanks man, this cleared my concept. I'm now gonna watch all your videos

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

    the best explanation i've found online so far

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

    Pedro, great job. I started to follow you some days ago and I am really enjoying your content! Congrats.

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

    I was just trying to translate an Axios request into fetch, now I know how. Thanks again, Pedro!

  • @yeer32
    @yeer32 3 года назад +2

    Finally a tutorial I could follow and not have to slow down playback speed. Do you have any flask + react authorization tutorials? Thanks a bunch!

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

      Thank you! Happy to hear you liked it! I am not that experienced with flask unfortunately!

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

      @@PedroTechnologies Unfortunate :( . Maybe its time to look into learning express or something, ill try and find some resources on your channel.

  • @ibesarah3263
    @ibesarah3263 Год назад +1

    Thank you so much for this video. A great help for beginners.

  • @kochgamers
    @kochgamers 3 года назад +2

    esse sotaque e nome nao me enganam, awesome video dude

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

    Crisp and clear...Too good...Thank u

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

    Love the way you simply explain it. Greetings from Sri Lanka

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

    Great and clear explanation with a few terrible jokes (which are totally my jam)! Thank you!

  • @CurtisxLarsen
    @CurtisxLarsen 4 года назад +12

    European --> It sounds a bit like - You are peein' -
    2 squared = 4 ---> "Too square" is slang for lame/uncool
    Pretty terrible jokes but thanks for the video

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

      Hahahaha I spent hours looking at the jokes from this API and i got like 30% of them

  • @electroviper5931
    @electroviper5931 3 года назад +4

    Note : If you want to learn Axios don't skip this video.

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

    you are very good teacher. Short video with clear explanation. keep it up.

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

    after seeing this video my all confusion is clear. Thanks, man!

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

    thankyou, this tutorial was very helpful. the jokes were hilarious btw.

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

    I think I might be becoming a fan. Thanks for the explanation

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

    That's exactly what I'm looking for.
    Thank you and keep going!

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

    Thanks bro , hey make sure to zoom in when you’re writing code , it was very tiny

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

    Good stuff man... Direct and to the point. Unlike those terrible random jokes! :) Also, what extension is displaying the the size of your imports?

  • @0Ipsita0
    @0Ipsita0 3 года назад +1

    It was really an amazing video. 🤩 It is having all points to get clear Ideas about axios and fetch. 😊

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

    THANK YOU! FOR THIS AMAZING STRAIGHT TO THE POINT TUTORIAL!!!!!

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

    Awesome no confusion now

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

    I like your tutorials. It really helps. Keep up the god work.

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

    if u have little kids around those jokes would kill lol. great tutorial btw. I been using fetch but seems axios is a bit quicker.

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

    This video really come through, thank you!

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

    Thank a million!! I like your video's. Could you make a vid showing how to setup a baseURL with a JWT header? those videos are hard to find

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

      Yeah, I've been putting off making my third video of a small series I have on my channel teaching about authentication. The third video teaching JWT is coming probably this week!

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

    Thank you so much! Because of this video I accomplished what I needed to.

  • @AnujJoshi7
    @AnujJoshi7 3 года назад +2

    How can We display the data without having to press the button? I tried by
    {name}
    But its not showing anything. I just wanted to remove the button input to display the data and show the data as soon as page loads

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

    The reaction to the jokes was hilarious 🤣🤣🤣🤣🤣

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

    This tutorial is super helpful!

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

    This video helped me so much! Thanks pedro

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

    Thank you so much!! You helped me a lot

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

    Great tutorial, but maybe you could have the browser and vsCode open side by side, instead of jumping between both programms.

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

      Thank you! I currently don't have 2 monitors, but im saving to buy another one! When I do I will keep vscode on one and the browser on another.

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

    This guy is good. He's speedy and efficient! Love it.

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

    please ask your content consumers like me to drop a like after we consume your content. It helps with me considering you seriously

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

    Dont know if you had gotten it yet, but the 2 Square joke is math lol ... " why didnt the 4 get into the club"

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

    EXTREMELY USEFUL video, thank you KINDLY friend

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

    Nice video. I know how to use fetch and I find it easier than axios haha. I still do not understand why I should use axios instead of fetch and all te advantages that I can get using Axios.

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

      Both do the same hahaha I think axios is easier to understand for beginners and it has a great support for changing methods/opts

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

    On point again. ThankQ Bro

  • @Tyler-zb6ec
    @Tyler-zb6ec 3 года назад

    Thank you!! great tut

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

    worth liking bro !

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

    Thx for video!=))) Where is the list of open api which you have mentioned in video?

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

    your videos are amazing

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

    thx. in nextjs or mern and so on, i use only axios ^^

  • @waynesrants
    @waynesrants Год назад +1

    I have not seen someone explaining the first joke so : If you're in the toilet, you are peeing (European)

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

    This is awesome, thank you :)

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

    the european punch is read like "you're peein' "
    youre welcome

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

    Hi i have a question, id i had a multiple jokes what should i do? store them in an Array??
    Thanks!!!!

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

      Yes! If the api returns a list you can set a state as an empty list!

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

    Please, how do we make a "post" request? Any link on that? Thank you.

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

    Hey sir. Can not we use axios or fetch directly in a component or can i make react component async

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

    can u pls make a vid how to use Axios and react on Node.js backed instead of other pre-made api's. make a small api and use it pls

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

    good explained bro

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

    Hi! What's this extension that display the size of the packages?

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

    Thanks PEDRO

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

    Great video. I am confused with setup?

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

      Thank you! What about the setup?

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

      @@PedroTechnologies response.data.setup. confused with setup word. where its come from

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

      @@junnaid08 It's nothing technical actually. It refers to the joke setup. In this data the joke is divided into to parts in the object (setup and punchline) { setup: "Can February March?", punchline: "No, but Aprill May" } so you can present it better in the app or show the punchline after the click etc.

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

    nice explanation

  • @ChobacarsPortHarcourt
    @ChobacarsPortHarcourt Месяц назад

    God bless you so much you will make heaven

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

    Is it possible to call getJoke without using a button? So when the page loads, the values are automatically shown in a label/textfield.

  • @SahilPatel-kh2rt
    @SahilPatel-kh2rt 3 года назад +2

    Hey I am curious to know your vs code theme please tell me the name of it

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

    bro i want a help with you to make travel guide application with axios

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

    Thanks for the vid, pretty clear. Btw, the API is down? I'm getting a 500 error. I can user another API though, but I wanted to get some jokes while I code. :(

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

    I'm using react + node express, when I am sending post request using axios api request, it sends request to locahost:3000,
    the localhost:3000 is my react server, and my node server is localhost:4000. I had set the "proxy":"locahost:3000"(in client/package.json) but it has no effect. pls help my.

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

      Hey if your node server is on the localhost:4000 then you should make the request to the localhost:4000!

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

      @@PedroTechnologies it is not working, I tried

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

    How do you load the data on load no event? just when the page loads it displays the joke without a button?

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

      You can use the useEffect hook for this, I have videos on useEffect if you are interested!

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

      @@PedroTechnologies I managed to figure it out I used useState and then just assigned the current state to the jsx html or w.e but when you reload the page the data doesn't get added instantly wound how you would get around that. Also, will check out your video on useEffect thanks for letting me know

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

    Best explanation

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

    can we do post and other request using fetch ??

  • @The-cyber-imbiber
    @The-cyber-imbiber 3 года назад +3

    I think I might have taken the "punch line" a bit too literally. Now, I need to buy a new monitor. /:

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

    There is axios.post and axios.get I am assuming fetch is axios.get. What would be axios.post? Post is sending a payload data to the API to be validated.

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

    Amazing 🙌

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

    thank you ! ❤

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

    Nice job Thanks!

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

    very helpful!

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

    the api link is not working

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

    the punch line is that "you are peeing"

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

    joke punchline explained. "European" as in "you're peeing" or shorthand "you're Peein" get it? lol but any who the video was amazing. thank you!!!

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

      Hahaha i'm dumb, I don't know why i didn't understand it!

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

    To the point 👍

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

    Just to explain the second joke, the word European is pronounced as "You are peeing" while in the bathroom.

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

      Thank youy hahaha Its actually pretty dumb of my part that I didn't understand lmao

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

    Thank you

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

    great video

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

    Thx so much

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

    KING

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

    i cant sleep, thinking about the joke all the time.. its so confusing what is it all about

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

    unfortunately that api is not working anymore..

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

    I love you bro

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

    Bruh, I really loved this video but I can't believe you didn't laugh at this jokes lol! European? lol

  • @isloom-vb7nk
    @isloom-vb7nk 2 года назад

    Api Link not working. Please repair it, bro

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

    i didnt get any response

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

    The joke at the 1:45, read European as "eu r pean" or "you are peein(g)".

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

    ❤️❤️❤️

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

    European = you’re-peein = you’re peeing

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

    API link not working anymore...link is a joke now !

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

    Hazlos en Español no seas mamón, te llamas pedro man seguro eres mexicano we, apoya al programador latino xd

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

    You're peeing 😝