1.1: fetch() - Working With Data & APIs in JavaScript

Поділитися
Вставка
  • Опубліковано 15 жов 2024
  • Welcome to Working with Data and APIs in Javascript!
    This course is for aspiring developers who want to learn how to work with data in web applications. How do you retrieve, collect, and store data? The course will be taught through a series of creating three data projects. This is the first video of the series!
    1.1 This video is client-side only and covers the web fetch() API, loading image data and focusing on handling asynchronous events with Promises (async / await),
    🎥 NEXT LESSON: • 1.2 Tabular Data - Wor...
    🎥 FULL COURSE: • Working with Data and ...
    💻github.com/Cod...
    🔗developer.mozi...
    🚂 Website: thecodingtrain....
    💖 Patreon: / codingtrain
    🛒 Store: www.designbyhu...
    📚 Books: www.amazon.com...
    🎥 Coding Challenges: • Coding Challenges
    🎥 Intro to Programming: • Start learning here!
    🔗 p5.js: p5js.org
    🔗 Processing: processing.org
    📄 Code of Conduct: github.com/Cod...

КОМЕНТАРІ • 451

  • @erichreinholtz
    @erichreinholtz 4 роки тому +100

    dude ur like the only person in this entire bloody internet who actually explained this properly

  • @jrichalot
    @jrichalot 5 років тому +160

    As a teacher, I can say this is mindblowingly brilliant! Oh man the effort that gets in producing a seamless and well constructed lesson like this is enormous. A massive thank you from me.

  • @beron_the_colossus
    @beron_the_colossus 5 років тому +111

    Ahh, it's finally here! Thank you Mr. Shiffman for everything that you do!

  • @sankai91
    @sankai91 5 років тому +24

    if only you'd have started this series about 4 years ago, it would have made my life back then so much easier!
    Finally got to understand it properly :)

  • @brikimbran
    @brikimbran 5 років тому +20

    Due to your pavlovian training with the bell, I now smile every time I your videos start Shiff. Excellent as always.

  • @JoSh-yu6jt
    @JoSh-yu6jt 5 років тому +8

    You are the god of programming tutorials. Your excitement and joy is contagious. If there was a person who could give birth to webDevs it's you. 😁👍🏻

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

    This is the type of content that pushes humanity forward. Thank you for empowering others.

  • @jamesa.
    @jamesa. 5 років тому +107

    Just in case you confused like I was- "rainbow.jpg" is a file on his computer, so you just navigate to an image on your computer too.

    • @HossamKhalaf-sr1oo
      @HossamKhalaf-sr1oo 4 роки тому

      Thank you!!!

    • @hkar19
      @hkar19 4 роки тому +5

      the thing is for me the fetch API cannot load. i just did what was written by Dan.
      the console said:
      URL scheme must be "http" or "https" for CORS request.

    • @hkar19
      @hkar19 4 роки тому +4

      oh ok it is done when i started the live server. i forgot that one

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

      but where do we define the path for that file?

    • @medilies
      @medilies 4 роки тому +16

      @@laalaajonsen
      "rainbow.jpeg" is a relative path
      Liveserver does load all the workspace (project folder ) on the network!
      So suppose that that the project folder is:
      Project ( index.html, img[ rainbow.jpeg ] ).
      Fetch with absolute path is like : "localhost:5500/img/rainbow.jpeg"
      Or with relative path is like:
      "Img/rainbow.jpeg"

  • @joshsinger8
    @joshsinger8 4 місяці тому

    Such a great teacher, not even fully into the series and I can already tell I'm in good hands 👍

  • @pablovillaverde679
    @pablovillaverde679 3 роки тому +8

    I am finally able and happy to report that I was able to write code to fetch an array of images and put them in a web page. I was also succesful to fetch the text in a .txt file. I have a good understanding of HTML and CSS and a few weeks of learning Javascript, so my next goal is to construct a web page to display analytic and historic information of Formula 1. There are a couple of API's available that I can use, so wish me luck!

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

      Did you succeed? Post a link to the live page if so!

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

    Wow! Amazing the way you explain how the code actually works behind the scene instead of just showing it. That is real teaching!
    Respect from Brazil!

  • @softmerit25
    @softmerit25 3 роки тому +7

    Seriously man. This is the best tutorial training I have ever seen in UA-cam so far. I'd love the way you teach, explain and illustrate. You're really doing great stuff. Thanks a lot.

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

      Would you happen to know what does 'img elt' means at the 8:55 mark ?? I've never heard of " ELT " before. Thanks a lot.

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

      where to get the rainbow file from ? where is this server please I am new to this

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

      @@omkarpabe7780 it could be any file off the internet or stored locally. In this case he's using an image off the internet that has the .jpg extension.

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

    As I am new in Javascript, but this guy could deliver precise explanation about it. Subscribe is a must !

  • @christopherburke7042
    @christopherburke7042 4 роки тому +12

    I am massively appreciative for everything that you are bringing to the table in this course, as well as by way of all the other resources you provide. God bless you man.

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

    I like how he made everything fun, even a person with no programming background can understand his explanation... I wish they taught me this way from the start

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

    After like 5 other walkthroughs that left me feeling stupid I'm realizing how poorly almost everyone else explains this stuff. Props to you for being a good teacher. Thank you.

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

    Wow.. this tutorial is perfect to context which gives real world example. Thank you very much.

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

    probably one of the best programming teachers.

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

    just came across your youtube videos, you have the most fun and vibrant coding lessons, and a teacher all children should have!

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

    How does it happen that whenever I am stuck at anything and cannot think of any solution at all, you just completely solve my problem and make me a happy person again. ❤

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

    the magic of FETCH-ing starts from 11:18 ASYNC & AWAIT --- awesome

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

    i always head straight to your videos on any topics i learn, because of the way you explain and energize me. I am literally happy while watching your vids!

  • @123saltgaming6
    @123saltgaming6 2 роки тому

    The best possible explanation that is available on UA-cam 👍👍

  • @thomaswilliams495
    @thomaswilliams495 5 років тому +2

    I absolutely love your tutorials. I'm astounded by how quickly you cover the information, jumping into code, error fixing, and rambling over so much territory with joy and humor. Math homework has never been this much fun!

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

    I feel like I am there in the class. I get him and what he is saying so well. Learning just got easier for me.

  • @nilsondelaossa4052
    @nilsondelaossa4052 10 місяців тому

    You are my code hero. Nobody explains so easily like you. Choo choo !

  • @nikolebianchini
    @nikolebianchini 3 роки тому +6

    I just love how he reminds me of my 6th grade teacher, like he literally has that same enthusiasm! Makes me really want to learn JS. Such an awesome job at keeping your viewers attention. I kinda wander off when learning on my own lol

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

    Been coding in C the past couple months can’t wait to come back to JavaScript.

  • @josepharcher9750
    @josepharcher9750 5 років тому +18

    You are so good at explaining everything! Thank you for the video :)

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

    one of the best video to explain js in the most simple way.

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

    I am new here and i came here to learn about api and i am damn sure that i will definitely learn too much from you Sir

  • @whenimnotaround
    @whenimnotaround 5 років тому +62

    VS Code has got an extension that is also called Live Server. It does basically the same thing, but for someone that has not yet played with node it might be simpler to use.

    • @AugustoFnrd
      @AugustoFnrd 5 років тому +2

      ​@@creeplabs idk about raspberry, but at least for linux distros, search for nvm (Node Version Manager)!

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

      @@creeplabs Installing node in linux under sudo is going to create lots of permission issues

    • @psylocke1517
      @psylocke1517 5 років тому +1

      just install it as a snap then > snapcraft.io/node

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

      @@matrezak it's only you put --unsafe-perm at the end of the line.
      sudo npm i -g node@latest --unsafe-perm
      xD

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

      sudo apt install npm && sudo npm i -g npm@latest && sudo npm i -g node@latest --unsafe-perm

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

    i'm glad to know english, just to say: thank you for all effort put on those videos.

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

    i have never enjoyed while learning something. You are soooo good in explaining stuffs.

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

    I finally understood fetch, in a way that I won't forget in 30 minutes. Great video!

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

    This stuff wasn't really setting right with me before. You helped me figure it click for me but that wasn't the best part of the video. You make it fun. Life doesn't have to be boring, why not make it fun? Thanks a ton!

  • @KanagawaMarcos
    @KanagawaMarcos 5 років тому +6

    One of the best coding channels out there. Amazing video Shiffman, thank you for it!

  • @akai746
    @akai746 4 роки тому +2

    Just the perfect course for my project. It's due on Tomorrow, hope I can complete it. This course has made my work much easier.

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

    This is soo informative and well done! I love your enthusiastic voice tone. I can't thank you enough. 👍🏽👍🏽👍🏽👍🏽👍🏽

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

    This is a BRILLIANT lesson! Its very good. Thank you

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

    even adds async/await in first video this guy is the internets end boss. good work.

  • @arindam-karmakar
    @arindam-karmakar 2 роки тому

    WHY DIDN'T I FOUND YOUR CHANNEL EARLIER! SUBSCRIBED!
    Thanks for the amazing contents!

  • @thomasyao66
    @thomasyao66 5 років тому +1

    You're content is so awesome. I'm going to join NYU as a grad student in Bioinformatics and am proud to be in the same institution as you.

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

    I like the happy energy you deliver so coding is less depressing :) thank you !

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

    Really like your style of teaching. You simplify concepts to the basic.

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

    Awesome lecture. I'm jobless at the moment, but I will subscribe to your channel as soon as I get a new job.

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

    You are my favorite teacher because you are so fun to watch so happy and animated thank you so much :)

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

    This is the first video of yours I've stumbled on and it's the best yet to break down fetch() with the added bonus of await/async. I'm a self-taught adult student and it's hard finding a teacher that clicks. Subscribed and looking forward to diving into the rest of your videos.

  • @francoisbouchet9907
    @francoisbouchet9907 3 роки тому +1

    i'm sorry, but the n00b in me has to say it loud... so here comes the CAPS:
    "IT'S BEEN DAAAAAYZ I AM STRUGGLING ON GETTING A SIMPLE API CALL TO JUST WORK AND LITERALLY NOBODY BUT CODING TRAIN TOOK THE TIME TO EXPLAIN & DEMONSTRATE IT IN A PRACTICAL MANNER (..and with such enthusiasm!) ! I FINALLY UNDERSTAND HOW IT WORKS! ALERT("THANK YOU SO SO MUCH!!

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

    I feel happy while studying from you.

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

    ur a god, beem strugling with fetch for a week, its easy to understand u

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

    Amazing ! Just discovered this channel because I was looking for how to use fetch and async, I understood all that stuff in this video. Thanks !

  • @art0van0derlay
    @art0van0derlay 4 місяці тому

    What a fantastic teacher! Keep up the good work

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

    Man what did we do to deserve a teacher like you❤️

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

    Thank you for the video! You made it easy to understand. I will try these exercises you suggested at the end of the video.

  • @AnjehMbah-n2l
    @AnjehMbah-n2l 2 місяці тому

    The only tutorial that made sense. Life saver!

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

    Thanks for this video man, and grateful for google for linking it as 3rd option for beginners looking for practical fetch API lessons.👍

  • @lukask6066
    @lukask6066 5 років тому +3

    The first time I really understand promises! LIKE!

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

    The best content and teaching method i ever seen. Thanks

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

    Excellent - thanks! Just subscribed and will be watching some more videos related to fetch and async await.

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

    Im showing this playlist to EVERYBODY! Congrats on the effort because this is helping me out a lot!

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

    Working with fetch and .then in my bootcamp. This helped me tremendously thank you so much

  • @felipef.tavares6251
    @felipef.tavares6251 Рік тому

    The exercises in the final part are really good! I used other API called dummyjson to put a random quote with the author of the quote in the page. Each time i reload the page is a different quote.

  • @abdel-karimosmanuazumah499
    @abdel-karimosmanuazumah499 2 роки тому

    i never really understood how to use api until i watched ur vid .

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

    Thank you, this concept is not easy to understand, but you explains it so clear that everybody can understand it now. Thank you for your effort and sharing.

  • @jorge88824
    @jorge88824 4 роки тому +2

    Basic concepts explained in an amazing way. Thank you once again for the great content and way of presenting it to the youtubers. You boosted my knowledge more than a whole semester at uni. Stay safe.

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

    This guy is awesome, Wish there was more time in the day to watch all his videos

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

    I love you. I have been searching for an easy way to retrieve an image from API and everyone was converting it into a base64 text. This si much easier, thanks !

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

    Bro, you are a lifesaver, thank you so much for the well delivered tutorial. You've provided the full context, focused on the function clearly, and chunked up the steps involved in an understandable and logical manner, which is really important for true comprehension.

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

    You and your channel are *brilliant*

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

    That was nice. I`ve seen no teacher as jolly as you. Thanks for the video :)

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

      Hey, do you know what the three calls to fetch() are?

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

    To be honest I'm amazed I was able to do it! I sort of followed along while you were explaining the await and blob concepts but I actually managed to get three rainbow images to display plus the text. Woo!

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

    Was coding along and I too kept on mispelling response too! Ahhh! Great tutorial. I enjoyed the challenge at the end which pushed me to make sure I understand how this all works! Looking forward to the rest!

  • @paulosilva-dm1qb
    @paulosilva-dm1qb 4 роки тому

    U r a genius and teaches with heart. What else can we need?...Alll happiness

  • @englishwitharash
    @englishwitharash 7 місяців тому

    you did really well. You said what we needed exactly.

  • @magicweaponr072
    @magicweaponr072 5 років тому +1

    You've mentioned "arraybuffer" at some point during the video. And I'd like a video with raw binary data manipulation and/or typed arrays. It is truly one of my dream videos that I would want to see!

  • @alperenozkan
    @alperenozkan 5 років тому +2

    Thanks 🙏 I really like your videos , your energy and the way you explain in front of the whiteboard. I feel like exactly in the class 💫👌

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

    I've been looking for this for a very long time!

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

    You're alright buddy... good vibes and its genuine

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

    Your tutorials are super duper awesome Mr. Shiffman. I'm learning and loving your contents. Keep it up

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

    You're a magician. You really found your vocation!

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

    Thank you, I had to scout a few videos with different teaching approaches and after 1-2 'explainer' videos and some stackoverflow posts I still didn't get "fetch" - putting it on whiteboard and the 'promise' aspect of the response really clinched the function for me. Thanks!

  • @hiryuimajin
    @hiryuimajin 5 років тому +1

    I enjoy your videos so much. This is so related to what im building and the way you explain things are very good. You enunciate and even the tempo is a bit faster its not that hard to follow. I appreciate you! 😘

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

    Finally some high quality tutorial, thanks dude

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

    This content and tutos are just, GOLD!

  • @clapynick
    @clapynick 5 років тому +2

    Nice video Dan :). One thing people often forget to do with fetch is to also look at the response! HTTP-level errors (eg: 404) are still considered resolutions, and so we're assuming that the response we get is fine to work with even though we may have ran into a HTTP-level error. A fix for this is to add a quick if-statement in the first _.then()_ callback:
    .then(response => {
    if(!response.ok) { // check for HTTP level errors, throw if error occurred
    throw new Error("Failed with HTTP code " +response.status); // reject
    }
    return response;
    }).then(result => result.blob()).then(...
    This way, any proceeding code/logic can assume that the response received is okay to work with.
    Thanks again for the videos, can't wait to see more :)

    • @TheCodingTrain
      @TheCodingTrain  5 років тому +1

      Oh, this is such a good tip, thank you!!

  • @scottcook9749
    @scottcook9749 5 років тому +11

    "I'm going to make an error happen just so we can see it"
    That's my secret Cap, I always have errors in my code.

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

    Dude you are amazing!! Fantastic video!

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

    I just want to say, you are the best.

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

    A massive thanks from here for your instructive lessons and your effort you're putting in this!
    Bow!

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

    You are the best teacher ever! Thank you so much for your videos! ❤️

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

    for people who is having trouble to define the path, first try to open the image using normally path on HTML tag page egs:

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

    Very interesting,learning with you.🌷

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

    Good fetch tutorial thanks. I have a question, Can I use fetch in combination with setInterval? The thing is that I have a json file that update every 10 seconds, and I need get the current data, to print in the html and handle the same data to do another stuff. What do you recommend to me?

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

    Hey King, you dropped this 👑

  • @marwabarakat2551
    @marwabarakat2551 9 місяців тому

    Thanks a lot for your efforts, you really make it seems to easy

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

    Exceptionally explained! Thanks

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

    Thank you for the videos!! so i managed to do the Fetch() API successfully . I now want to pass the SRC with the encrypted payload to a browser . How can i achive that please assist ?

  • @tunafish9112
    @tunafish9112 5 років тому +2

    I love your videos dude, can't wait to go through this series!

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

    The best teacher! Thanks for your awesome work