Fetching Data in React - Complete Tutorial

  Рет қаралды 143,282

Cosden Solutions

Cosden Solutions

Күн бұрын

Пікірлер: 137
@cosdensolutions
@cosdensolutions 8 ай бұрын
Hope you enjoyed the video! I also have a really cool and unique course that will teach you way more than this video. You'll learn how to build an actual complex project with React. It's called "Project React" and you can find it at cosden.solutions/project-react. Also, I have a free weekly newsletter called "Import React" with tutorials, news, and cool stuff about React! You can sign up at cosden.solutions/newsletter?s=ytc
@opyotusamuel
@opyotusamuel 3 ай бұрын
😅😅😅😅😅😅
@amritghimire4791
@amritghimire4791 3 ай бұрын
😊
@shya666
@shya666 Сағат бұрын
Talking about race conditions for a language that is not even multi-threaded is wild. But a very well-made tutorial. Thank you.
@craig1253
@craig1253 9 ай бұрын
Been stuck learning react for months and now I found this gem of a channel. Keep it up bro!
@mohamedsaed1558
@mohamedsaed1558 22 күн бұрын
in my mind I was thinking that if I find a teacher teach me every piece of code, then I find you, you make code incredible easy, and completely for free, only teacher like you can only create channel you , I wish for you all the best
@Securitywasted
@Securitywasted 4 ай бұрын
Best data fetching video in react i have ever seen. Expain every step in details Keep it up bro
@betull7
@betull7 4 ай бұрын
this channel single-handedly saves my life
@KonstantinosKaminaris-xe8wt
@KonstantinosKaminaris-xe8wt 6 ай бұрын
I aspire to one day be able to teach people like you do. This is really high quality teaching my friend. Respect.
@НикитаБурлаков-у8ш
@НикитаБурлаков-у8ш 8 ай бұрын
I think u should also add some check statement for response.ok, because this is common case in handling responses from your own API, and u can receive response with status 400(some form validation error) or 500(some server internal error) and that's why its good practice to throw Error when !response.ok, btw, thanks for the video
@praulayar4805
@praulayar4805 11 ай бұрын
one of the best video on data fetching with vanilla data fetching
@moviegift2492
@moviegift2492 5 ай бұрын
I like your way of teaching and I am new for react, i came from backend zone so I am here for the next coding sessions to see how really manages my love of data. Thank you for your effort. u got one sub.
@webdev-tom
@webdev-tom Жыл бұрын
Your videos are such a masterpiece 👍 I really hope your channel will grow very fast because you deserve it so much. Really good quality content 💯
@cosdensolutions
@cosdensolutions Жыл бұрын
thanks a lot! I hope so too!
@madhavvankina5201
@madhavvankina5201 Жыл бұрын
Your channel is gonna pop off. Your content is top-notch 💯💯
@reihane2325
@reihane2325 10 ай бұрын
Thanks a lot for explain very clear. I saw lots of video in KZbin, but your explain is so helpful for me as a junior react typescript developer. Bon courage!
@jellyfish1772
@jellyfish1772 Жыл бұрын
Just when i saw you were using typescript I knew this would be a great tutorial. great video❤
@KojoJohnson
@KojoJohnson 4 ай бұрын
I just subscribed live from Ghana West Africa, you teach very clean and straight fwd learned alot from you the least i can do is sub
@erikreyes6093
@erikreyes6093 Жыл бұрын
wow very informative tutorial, there is so much to learn from you. I just hope you will keep creating vidoes that share your expertise in web development
@cosdensolutions
@cosdensolutions Жыл бұрын
will do!
@KarenDiaz-m6m
@KarenDiaz-m6m Жыл бұрын
This video was extremely informative! Looking forward to watching more React content from your channel. Would be great if you could also make a best practices video for production code or even intermediate/advanced React videos
@iCeTainment
@iCeTainment Жыл бұрын
I just subscribed 🎉 Love your videos man! It’s helping me with my internship projects
@cosdensolutions
@cosdensolutions Жыл бұрын
glad to hear it!
@rishabhnegi9429
@rishabhnegi9429 10 ай бұрын
I am just obsessed with your videoes ... great work 😀
@lisalee7946
@lisalee7946 8 ай бұрын
Best instructor!! Thank you for such great content!!💯
@ooorayooonyoooo
@ooorayooonyoooo Жыл бұрын
bro you are always just straight to the point. Thanks Man!
@shahnawazk
@shahnawazk 9 ай бұрын
One video to like and subscribe! Really helpful and informative. Thanks and keep it up.
@ashsad521
@ashsad521 Ай бұрын
Thanks very much for that great video, very clear and organized
@lilynn7777
@lilynn7777 8 ай бұрын
I was trying to start the core of your project and i was keep getting an error. I believe i re-wrote it like 4 times. And then i realized something i never learned before during my Bootcamp: you have everything with tsx lol. What i was trying to do, was to write everything in jsx. So i looked it up and apparently there is a "create react with typescript" 😵‍💫 and now it shows everything. Learning something new every day. Althought i am still a bit confused between tsx and jsx and their usage
@tigranharutyunyan7674
@tigranharutyunyan7674 11 ай бұрын
Enthusiasm and knowledge! Thank you man
@goodness776
@goodness776 Жыл бұрын
Never seen a lean step by step explanation. You are indeed a masterpiece @webdev-tom💯
@rellamwahid6392
@rellamwahid6392 7 ай бұрын
thank you for the video, i think you should add a cleanup function in the useEffect hook to cancel any ongoing requests when the component unmounts or when page changes (talking about the abort ).
@farhaannishtar786
@farhaannishtar786 8 ай бұрын
This guy is good. Thanks for making great content
@djwooster
@djwooster 4 ай бұрын
Love this explanation! May I suggest that you perhaps get a pop filter or somehow edit the audio (probably some quick AI solution) because every time you pronounce a 'p' sound it's loud af in my headphones lol but I LOVE the video!
@incarnateTheGreat
@incarnateTheGreat 7 ай бұрын
Thanks for the Abort Controller solution!
@tylerxx26
@tylerxx26 9 ай бұрын
Super stuff man. Please keep it up!🎉
@kreten780
@kreten780 Жыл бұрын
For loading, I really like to use an object of properties like: const FETCH_STATUS = {IDLE: 'idle', LOADING: 'loading', ERROR: 'error', SUCCESS: 'success'}; In that way I have a little bit more control over what I display on different occasions.
@cosdensolutions
@cosdensolutions Жыл бұрын
yep, that's another way to do it!
@hilkiahlavinier
@hilkiahlavinier Жыл бұрын
Thanks for this great video. Will you consider doing a follow up video that discusses the pros/cons of the various (or most popular) React fetch methods/options (e.g. Axios et al) and suggest their usecases (when to use one over the other)?
@cosdensolutions
@cosdensolutions Жыл бұрын
Hmm not a bad idea tbh, will note it down!
@vesa95
@vesa95 Жыл бұрын
Fire man! 🔥 I’ve wait for you to post!
@cosdensolutions
@cosdensolutions Жыл бұрын
Yes! More videos to come! I'm currently on vacation so I've posted a bit less
@2difficult2do
@2difficult2do Жыл бұрын
This is very interesting video, exactly what I looking for. Thank you. Like
@cosdensolutions
@cosdensolutions Жыл бұрын
glad you found it useful!
@wallethe1614
@wallethe1614 Жыл бұрын
Awesome vid im learning alot, thank you and keep it going.
@cosdensolutions
@cosdensolutions Жыл бұрын
glad to hear it!
@hamzapaskingakhtar
@hamzapaskingakhtar Жыл бұрын
This is pure gold
@Pareshbpatel
@Pareshbpatel 3 ай бұрын
Data Fetching in React, so clearly explained. Thanks, Darius. {2024-08-27}
@MaxMov-sp8hr
@MaxMov-sp8hr 9 ай бұрын
One of the best! 👏
@irfansaeedkhan7242
@irfansaeedkhan7242 3 ай бұрын
again with the ooint the more seniors I talked to they said don't use useEffect for API calls because first UI is rendered then useEffect runs, so its like render first then fetch data, but if you use rtk query it fetch first and then re render so UI comes with no glitch also it cache ur data, so useeffect sometimes causes too many renders issue if not done right, specially API calls is not recommended , in your react project course have you done API call same in useEffects or you have done them in differently ways as well ? i am planing to purchase it because the way you explain things is perfect
@TLTechbender
@TLTechbender 5 ай бұрын
Thanks so much, you just helped me out big time!
@jlogo80
@jlogo80 Жыл бұрын
Awesome stuff, thanks!
@helenasdiaries515
@helenasdiaries515 10 ай бұрын
Thanks ! You are a great explainer
@mafterr11
@mafterr11 3 ай бұрын
Outdated, since useEffect isnt really recomended for fetching anymore. Better ways to do it. Would love to see an updated video of this :)
@cosdensolutions
@cosdensolutions 3 ай бұрын
actually posting that tomorrow :D. You're right, this is outdated, but still important if you're learning. You need to know and understand how to do this before moving on to RQ or server components
@enedigodswill
@enedigodswill 2 ай бұрын
Exactly I'm facing the same issue too, I'm still a beginner and I really need help with it
@frankdearr2772
@frankdearr2772 2 ай бұрын
Great, thanks for all 👍
@MikeTheCook
@MikeTheCook 9 ай бұрын
Love it. You're the best.
@Lidkovsky
@Lidkovsky Жыл бұрын
golden content.
@ramirorenteria7333
@ramirorenteria7333 6 ай бұрын
Awesome tutorial!
@rajnishkushx
@rajnishkushx 10 ай бұрын
Luv bro, from Bharat ❤
@theMaroFlow
@theMaroFlow 3 ай бұрын
Hi, this is amazing video i learn a lot, but wondering if in this code implementation need to add clean up function or this code is full correct and clean up not required.
@INetreba
@INetreba 9 ай бұрын
very good explanation!
@DrivingScape
@DrivingScape 2 ай бұрын
Nice vid, thanks
@dardaniaa0546
@dardaniaa0546 9 ай бұрын
React Query makes this super easy
@cosdensolutions
@cosdensolutions 9 ай бұрын
it does
@Riflijones01
@Riflijones01 8 ай бұрын
You WILL want to watch another video on Fetching Data. Watch as many as you can because that will show you that there are other ways of doing things
@shashwatgupta2184
@shashwatgupta2184 7 ай бұрын
Can you provide few links looks like you already seen some different ways
@TausifShekh-j5x
@TausifShekh-j5x Жыл бұрын
please make videos on doing project. your channel is growing since last time i commented doing great keep it up i am your subscriber
@cosdensolutions
@cosdensolutions Жыл бұрын
How about livestreaming building an entire app from scratch, while also making it open source so anybody can contribute no matter the skill level? It'll be a great way to learn and build something real! And also, no worries, all videos will be available even after the live stream!
@TausifShekh-j5x
@TausifShekh-j5x Жыл бұрын
@@cosdensolutions yes thats good idea
@harag9
@harag9 Жыл бұрын
Great video. The main different I do is with the abortController, I always put that in the cleanup return, which is what I've seen in several other videos on the same topic, it's interesting to see you doing it differently, both ways look like it will work just as well though. As for React Query you mentioned, do you plan on doing a tutorial on that?
@cosdensolutions
@cosdensolutions Жыл бұрын
Yeah that's another way to do it! And the RQ video has been up for a while already ☺️
@harag9
@harag9 Жыл бұрын
@@cosdensolutions Ahh cool, still working my way through the videos. :) Really enjoying them .
@thisstory
@thisstory 9 ай бұрын
Love your videos
@haroonkhan-dy9bt
@haroonkhan-dy9bt Жыл бұрын
Hey great tutorials will do a context api tutorial with fetching data and adding a cart functionality etc?
@cosdensolutions
@cosdensolutions Жыл бұрын
Haven't gotten around to doing tutorials of actual features but yes, I will do! However I have already a tutorial on useContext 😁
@memeMerge
@memeMerge Жыл бұрын
I really liked it 👍👍
@Oshione-w9c
@Oshione-w9c Жыл бұрын
excellent video very imformative guy
@haiderjaafer8164
@haiderjaafer8164 Жыл бұрын
So useState is the Post a class previously you created so it here generic... Hope to clarify that... Thank
@cosdensolutions
@cosdensolutions Жыл бұрын
Yes, I created a type of Post, with id and title. There are more properties from the API but since we only use those, I just created that type!
@aswineepratihari7897
@aswineepratihari7897 10 ай бұрын
21:38 abort control
@BLUEGAMER26
@BLUEGAMER26 2 ай бұрын
You’re an angel, I was looking for this
@garikmelqonyan6011
@garikmelqonyan6011 9 ай бұрын
Good job!
@erikreyes6093
@erikreyes6093 Жыл бұрын
Can you create a tutorial that shows the actual sql query that fetch records from database please. A plain sql query and sql that uses views and stored procedure please Thank you very much
@cosdensolutions
@cosdensolutions Жыл бұрын
probably not for a while, I am focusing on react at the moment!
@jay-kv6wn
@jay-kv6wn Жыл бұрын
Great content
@aggranular
@aggranular 5 ай бұрын
If you don’t care about type of error you should use unknown, not any
@piotrszczesniak
@piotrszczesniak 9 ай бұрын
Hey Cosden! Thanks for the video. I never considered, or even never heard of, cancelling the racing condition. What I would normally do it is to disable the button that fires another call when the isLoading is true - it does the job 🚀. What do you think about my solution?
@cosdensolutions
@cosdensolutions 9 ай бұрын
It would work, but then you're blocking the UI waiting for a response. What if the user changes their mind before the request returns? It's easier to let them change their mind and just cancel the pending request
@piotrszczesniak
@piotrszczesniak 9 ай бұрын
@@cosdensolutions I agree with you. Actually, this is the first time I heard about the abortController(). I will keep this video as a reference when I develop sth that would need the abortController(). In my case, using isLoading to disable the UI for a second is a good enough option :)
@haiderjaafer8164
@haiderjaafer8164 Жыл бұрын
Really great keep going forward... But learning react in js not in type script
@cosdensolutions
@cosdensolutions Жыл бұрын
that's fine! Just ignore the types then! But it would be useful to just be familiar with it, so that when you eventually do go to typescript (you should), you'll be more familiar!
@joshuac9142
@joshuac9142 6 ай бұрын
Perfect!
@AkbarAli-bt7xi
@AkbarAli-bt7xi 2 ай бұрын
thanks sir
@capt_vj
@capt_vj 9 ай бұрын
awesome !
@СандугашАхметжанова-п5ф
@СандугашАхметжанова-п5ф Жыл бұрын
please make a video about typescript, this new syntax sometimes shocks me
@cosdensolutions
@cosdensolutions Жыл бұрын
Will do!
@hameeeed5992
@hameeeed5992 5 ай бұрын
Thanks
@abdalghanialbiek8999
@abdalghanialbiek8999 11 ай бұрын
I wish to play this sound when Eren meet Anni in all timelines
@MuhammadWaqas-eb1uu
@MuhammadWaqas-eb1uu 8 ай бұрын
Can I use hook useloader as async fucntion to fetch api data. That is optimize way and performance application increase.
@richardleungwoogabriel9317
@richardleungwoogabriel9317 Жыл бұрын
Great video! But I’m trying to get in your discord channel but I need an invite link. The link in the description doesn’t work for me
@cosdensolutions
@cosdensolutions Жыл бұрын
it should work, or just manually go to discord.cosdensolutions.io
@JonathanKila
@JonathanKila 9 ай бұрын
Any resource on data fetching and caching? Like why should I use React Query, SWR?
@cosdensolutions
@cosdensolutions 9 ай бұрын
I have a video on RQ as well
@abhinasregmi9742
@abhinasregmi9742 9 ай бұрын
I was wondering if we could add signal aborting in cleanup for useEffect instead at the top 🤔🤔 Will this work??
@cosdensolutions
@cosdensolutions 9 ай бұрын
yes it would, it's actually better!
@maryambibi9687
@maryambibi9687 11 ай бұрын
Can you make one video in react life cycles ?
@MarkDavid-so9up
@MarkDavid-so9up 10 ай бұрын
Which is better? const fn = async() => {} fn() Or (async(){})()
@apoorvgupta9680
@apoorvgupta9680 3 ай бұрын
we can also return request.abort
@EzekielOladejo-f1u
@EzekielOladejo-f1u Жыл бұрын
What theme is this? Does anyone know? Thank you in advance 🙏🙏
@cosdensolutions
@cosdensolutions Жыл бұрын
Material theme darker
@EzekielOladejo-f1u
@EzekielOladejo-f1u Жыл бұрын
@@cosdensolutions Thank you!!
@faisalhussain7008
@faisalhussain7008 9 ай бұрын
What if we abort the request inside the cleanup function?
@cosdensolutions
@cosdensolutions 9 ай бұрын
Yeah that's better!
@kkatsavaros
@kkatsavaros 9 ай бұрын
Thank you, but why i take back two responses,? These responses are the same.
@cosdensolutions
@cosdensolutions 9 ай бұрын
Maybe because you're in strict mode and React fires all useEffects twice
@kkatsavaros
@kkatsavaros 9 ай бұрын
Yes, exactly. Thank you very much.
@aggranular
@aggranular 5 ай бұрын
I like your video but got a big fat 👎 for as Posts[] antipattern. Should have at least mentioned that in real application you should validate the response a type safe schema library
@sehlanarslan1792
@sehlanarslan1792 9 ай бұрын
@AyushManShrestha
@AyushManShrestha 11 ай бұрын
TypeError: posts.map is not a function {isLoading && Loading...} {!isLoading && ( {posts.map((post) => { return {post.title}; })} )}
@bidsouravbest
@bidsouravbest 9 ай бұрын
Pls make your codes on JS. PLS
@cosdensolutions
@cosdensolutions 9 ай бұрын
just ignore the types
@ABDULLAHKHALID-ix6db
@ABDULLAHKHALID-ix6db 10 ай бұрын
@marcrichet2626
@marcrichet2626 Жыл бұрын
Bonsoir, What's your vscode theme please? :)
@sumeettiwari4060
@sumeettiwari4060 Жыл бұрын
Material theme
@rodriruiz7654
@rodriruiz7654 Ай бұрын
Stop trying to make fetch happen!!
@brandonhopkins3438
@brandonhopkins3438 Жыл бұрын
Big shame it's written in typescript. Still, transferred it to js and this was a great tutorial. Liked. Subscribed.
@cosdensolutions
@cosdensolutions Жыл бұрын
No problem if you use JS, but my advice is to start thinking about TS because it will probably become the standard eventually!
@harag9
@harag9 Жыл бұрын
As Darius has said, I too would recommend picking up TS and learning that, it really does help.
@josepdevillaret
@josepdevillaret 6 ай бұрын
Can i contact you personally? I've got a project I'd like to get some React expertise in order to set a cart onto Framer (via React)
@josepdevillaret
@josepdevillaret 6 ай бұрын
by connecting shopify backend onto framer frontend (via embeded code)
@Anilsinghchd
@Anilsinghchd 6 ай бұрын
Great content
Folder structure in React - Complete Guide
12:35
Cosden Solutions
Рет қаралды 89 М.
Modern Data Fetching in React (Complete Guide)
16:41
Cosden Solutions
Рет қаралды 68 М.
How Many Balloons To Make A Store Fly?
00:22
MrBeast
Рет қаралды 150 МЛН
Players push long pins through a cardboard box attempting to pop the balloon!
00:31
Увеличили моцареллу для @Lorenzo.bagnati
00:48
Кушать Хочу
Рет қаралды 8 МЛН
УДИВИЛ ВСЕХ СВОИМ УХОДОМ!😳 #shorts
00:49
HARD_MMA
Рет қаралды 3,7 МЛН
React Query - Complete Tutorial
18:57
Cosden Solutions
Рет қаралды 143 М.
How to FETCH data from an API using JavaScript ↩️
14:17
Bro Code
Рет қаралды 158 М.
Learn React Hooks: useMemo - Simply Explained!
13:41
Cosden Solutions
Рет қаралды 113 М.
My Favorite Way to Fetch Data in React
16:28
Josh tried coding
Рет қаралды 72 М.
How is this Website so fast!?
13:39
Wes Bos
Рет қаралды 1 МЛН
How to Build a SaaS with InfraNodus and Windsurf AI (Tutorial)
28:27
DRM explained - How Netflix prevents you from downloading videos?
18:17
Mehul - Codedamn
Рет қаралды 227 М.
ReactJS Course [7] - How To Fetch Data From an API in React
30:20
Redux - Complete Tutorial (with Redux Toolkit)
37:01
Cosden Solutions
Рет қаралды 243 М.
Learn React Hooks: useEffect - Simply Explained!
14:07
Cosden Solutions
Рет қаралды 168 М.
How Many Balloons To Make A Store Fly?
00:22
MrBeast
Рет қаралды 150 МЛН