4 Ways To Fetch Data in React

  Рет қаралды 57,635

PedroTech

PedroTech

Күн бұрын

Пікірлер
@behold_a_son
@behold_a_son 2 жыл бұрын
2:49 The result is not JSON, here's a quote from mdn on Response.json(): "Note that despite the method being named json(), the result is not JSON but is instead the result of taking JSON as input and parsing it to produce a JavaScript object." So correct me if I am wrong: the result obtained after the fetch promise has fulfilled, is already in JSON. When you do res.json(), it returns another promise that converts JSON into a JavaScript Object, so you can for example use the dot operator on the data when the returned promise of res.json() is fulfilled. We all are learning! Don't let a mistake like that haunt you Pedro! You've been a great help to me! :)
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
Yes! The way i said it came out wrong, but you are right 🙂 The function parses a json into a js object.
@madalinavasile5930
@madalinavasile5930 2 жыл бұрын
Hi! I just want to say a big thank you! For my graduation project/bachelor thesis I decided to make an app using React. It was a totally new technology for me and the first app I ever made. Finding your tutorials and videos was been really helpful, they're really easy to follow and your explications and examples are great! I'll have to make sure to go back to every video I watched and leave a like. Good job and hopefully more people will find your channel!
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
This makes me really happy! Im glad you were able to learn from my videos 🙂
@fandross_
@fandross_ 2 жыл бұрын
E ai mano, tu eh o melhor professor que eu ja tive, valeu ai!
@universecode1101
@universecode1101 2 жыл бұрын
This is a very important step guys … good video Pedro 👏🏻
@_boza
@_boza 2 жыл бұрын
I heard and use some basics of React Query but you mentioned many things that I did not know and they are very useful! Thank you! :)
@pookiepats
@pookiepats Жыл бұрын
Thanks!
@PedroTechnologies
@PedroTechnologies Жыл бұрын
Thank you so much for the support!!
@Moon-li9ki
@Moon-li9ki 2 жыл бұрын
boa pedrão, teus videos sempre me ajuda demais! Nem sabia q vc era brasileiro, seu inglês é muito bom
@arsnakehert
@arsnakehert 2 жыл бұрын
Your channel is a treasure of knowledge, man
@ioana4011
@ioana4011 6 ай бұрын
Thank you so much, Pedro, for the video. I have been watching many videos, but yours are by far more helpful. Would you be able to do a tutorial on Nivo charts API integration? This topic is poorly documented and it would help tremendously to have your guidance. I am pretty sure I am not the only one searching for it 😅. Many thanks 😊
@nomapos
@nomapos 2 жыл бұрын
Hello, please we need some react native content .... Even if it's only notes ... Please share ...🙌🙌
@diegounanue
@diegounanue 2 жыл бұрын
More videos about how to structure a large project with react query :)
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
Will do!
@filipevalentegomes2383
@filipevalentegomes2383 2 жыл бұрын
I’m surprised you didn’t mention rtk query, that’s another one, lots of people love using. Still great video
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
Rtk query is good! I didn't mention because I don't use it that much (very few times) so I can't explain it to the best of my habilities
@theUnsungWarriorr
@theUnsungWarriorr 2 жыл бұрын
RTK query is so cool 🙂
@michealdalu8620
@michealdalu8620 2 жыл бұрын
This is gold .. thanks 🙌🏽👏🏾👏🏾👏🏾
@WTFBRUTUS
@WTFBRUTUS 2 жыл бұрын
Just what I needed to know thanks!!
@sethheinzman5823
@sethheinzman5823 2 жыл бұрын
You can also use SWR config to set a fetcher and set the suspense for all of the useSWR so you can just include the url and nothing else. That’s how this book taught it but I kind of like having the option to change the fetcher.
@sohadmad1823
@sohadmad1823 Жыл бұрын
Thank you , very useful video ❤
@EduardKaresli
@EduardKaresli 2 жыл бұрын
There is also RTK Query, from Redux Toolkit.
@mentoriii3475
@mentoriii3475 2 жыл бұрын
1:55 fetch api is a browser api, technically not built in into javascript but in the browser
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
Yes you are right! In the video I meant to say that u can use i without installing any library (such as axios). I see how it sounds wrong now hahaha
@tech3425
@tech3425 2 жыл бұрын
Cool vid. Would love to see something like using react query with firebase, if that's something you find interesting.
@user-uw1rh4dg1y
@user-uw1rh4dg1y 2 жыл бұрын
Questions can come in⬆️.
@Hacking-NASSA-with-HTML
@Hacking-NASSA-with-HTML Жыл бұрын
Thank you so much, sir 👍♥️🤝
@GabrielMartinez-ez9ue
@GabrielMartinez-ez9ue 2 жыл бұрын
Thank you dude. Is the suspense new feature still experimental or can it be used in production for nextjs apps?
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
Its not experimental anymore, it came with react 18!
@faisalamin001
@faisalamin001 2 жыл бұрын
Please also make video on testing i.e Jest etc Thanks
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
Just posted one a couple hours ago hahaha
@faisalamin001
@faisalamin001 2 жыл бұрын
@@PedroTechnologies wow, hahahah thanks bro ❤
@DeepLook1
@DeepLook1 2 жыл бұрын
Thank uuuuuuuu . And how many ways we have to insert record to database like mysql. Thank u again for this video
@adarsh-chakraborty
@adarsh-chakraborty 2 жыл бұрын
I wish you showed stale option in react-Query. Anyways nice video!!
@jorge.camargo
@jorge.camargo Жыл бұрын
Fantastic. Thank you!
@atandauthman2126
@atandauthman2126 2 жыл бұрын
I can see you have the copilot extension, I'm sort of having issues getting my own to work I don't know what I'm doing wrong but it shows the icon as cancelled every time
@varaprasad6531
@varaprasad6531 2 жыл бұрын
Thanks Pedro!
@shinobi_coder88
@shinobi_coder88 2 жыл бұрын
Hey Pedro, just wanna clarify that in React 18 anytime when there's sth to do with api we no longer need to use useEffect() right? Since React Query benefits our performance better. Honestly I've tried both Pagination and Infinite Scroll in React Query which are really good in React app. However, when I use React Query in NextJs that's where I feel it slows down the app performance a bit.
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
I mean, it depends on how your app is running. I usually use SWR when im working in a nextjs app and react query when I am not. But both should be good, try to optimize the way your are fetching ur data and see if it is react query that is really causing the issue. For example, are you paginating by fetching data incrementally?
@shinobi_coder88
@shinobi_coder88 2 жыл бұрын
@@PedroTechnologies what do you mean by incrementally? In my scenario, for example Rick and Morty API, when it comes to NextJs the only thing that React Query helps is prefetching data with SSR or SSG. But when clicking to the next new page (which is not the previous data yet) then it renders not as fast as React App. On the other hand, I have also tried to fetch Weather API with React Query in NextJs and it seems quite slow too compared to using only SSR to fetch the data from Weather API
@shinobi_coder88
@shinobi_coder88 2 жыл бұрын
@@PedroTechnologies I'm also curious what makes you choose SWR instead of React Query for NextJs App ?
@ramonarthur2729
@ramonarthur2729 2 жыл бұрын
@@shinobi_coder88 export const getStaticProps: GetStaticProps = async (context) => { const { slug } = context.params as IParams; const queryClient = new QueryClient(); await queryClient.prefetchQuery(['product', slug], () => fetchProduct(slug)); await queryClient.prefetchQuery('products', fetchProducts); return { props: { dehydratedState: dehydrate(queryClient), }, }; };
@ramonarthur2729
@ramonarthur2729 2 жыл бұрын
@@shinobi_coder88 export default function ProductDetails() { const router = useRouter(); const { slug } = router.query as IParams; const { data: product } = useQuery(['product', slug], () => fetchProduct(slug) ); const { data: products } = useQuery('products', fetchProducts); if (!product) return ; .....
@Ellenox147
@Ellenox147 2 жыл бұрын
Great video thanks ! What's the theme plzzzzzzz ?
@AM-nm6ts
@AM-nm6ts 2 жыл бұрын
please if it's possible, when u have time, ---> context api vs prop drilling thanks a lot
@sonamohialdin3376
@sonamohialdin3376 2 жыл бұрын
Awesome tutorial
@renesalvacion6169
@renesalvacion6169 2 жыл бұрын
Do I need to fetch data in react, if I used nodejs for backend?
@adarsh-chakraborty
@adarsh-chakraborty 2 жыл бұрын
Yes frontend needs to do network requests to get data from backend. Doesn't matter if it's node server, python or java.
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
The frontend has to fetch the data from the backend in order to get the data.
@sudiptokumarmitra9845
@sudiptokumarmitra9845 2 жыл бұрын
Can you please make a project-based tutorial using the redux toolkit and react query and show how to create industry standard coding and folder structure??
@songokussj4cz
@songokussj4cz 2 жыл бұрын
+1 ! Show us something real, please. Best practices in your opinion.
@licokr
@licokr 2 жыл бұрын
Thank you so much! Great!
@manasahr478
@manasahr478 Жыл бұрын
Could you please help me how to fetch data from mssql database stored procedure to reactjs
@jackiedo7370
@jackiedo7370 2 жыл бұрын
just cmt to say thank you ❤
@himanshugaikwad4998
@himanshugaikwad4998 2 жыл бұрын
Nice video like always. Thank you very much. Can u make a video on auto image slider in react js? i would love to learn that from u
@icecream5335
@icecream5335 2 жыл бұрын
I want to fetch the data from the server which uses jwt auth. Please help me.
@Lunolux
@Lunolux Жыл бұрын
great video, thx
@nazmulalam1982
@nazmulalam1982 2 жыл бұрын
18 version is fast but 16 version too slow my office project running 16 version how to fast do it?
@sujoykrhaldar
@sujoykrhaldar 2 жыл бұрын
hi Can you make a series on how to use swr client side fetching in nextjs and react query as well.
@patrickorji3616
@patrickorji3616 2 жыл бұрын
I don't have anything displaying on my browser when I use the Fetch API and Axios API. All my codes are correct just like that of Pedro's. I will appreciate a response
@abdirahmann
@abdirahmann 2 жыл бұрын
am dead 29:29 "writting code that doesn't male sense"
@stephengatonga844
@stephengatonga844 2 жыл бұрын
Hi, am using axios to fetch data but am getting this kind of error...... AxiosError: Network Error
@fullfungo
@fullfungo Жыл бұрын
There might be an error with your network.
@stephengatonga844
@stephengatonga844 Жыл бұрын
@@fullfungo I have come a long way😅, at that time such an error gave me headaches now am good at react.js and react native🤣 Thank you for the response anyway.
@smartjefreycoca5425
@smartjefreycoca5425 2 жыл бұрын
Brother pedro can you make a tuotrial creating a User Management System using React Js and MUI
@user-uw1rh4dg1y
@user-uw1rh4dg1y 2 жыл бұрын
Questions can come in⬆️.
@vnm_8945
@vnm_8945 2 жыл бұрын
love it!
@kabagambedaniel2468
@kabagambedaniel2468 2 жыл бұрын
nice one
@MyALPHAguy
@MyALPHAguy 2 жыл бұрын
ainda bem que vc não usou o typescript
@ts8960
@ts8960 2 жыл бұрын
async await is the best way.
@aghilannathan8169
@aghilannathan8169 2 жыл бұрын
Damn to Redux Toolkit Query.
@abulazaiemabas5070
@abulazaiemabas5070 2 жыл бұрын
Fetch api is built-in the browser not node
@SahraClayton
@SahraClayton 2 жыл бұрын
React Query is by no means a state solution, also I like your videos but just get to the point, it took you over 4 minutes from the start of the React Query part to even get to the point of React Query
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
Couldn’t agree more!
@mr-36
@mr-36 2 жыл бұрын
Fetch is not part of javascript. Fetch belongs to BOM(browser object model)
@nanimys
@nanimys 2 жыл бұрын
in turn, belongs to the javascript library!!
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
I meant that when you are using javascript, you don’t have to download any extra library to use the fetch api.
@mentoriii3475
@mentoriii3475 2 жыл бұрын
@@nanimys no sir, there is a reason it's called an api, we use it on javascript but it's not built in javascript
@mr-36
@mr-36 2 жыл бұрын
@@mentoriii3475 Exactly!
@RicardoGuillen
@RicardoGuillen 2 жыл бұрын
You forgot RTK Query :/
@PedroTechnologies
@PedroTechnologies 2 жыл бұрын
RTK Query is interesting, but I don't use it a lot since I am not that fond about Redux
@RicardoGuillen
@RicardoGuillen 2 жыл бұрын
what do you recommend to use with Zustand? Zustand + React Query?
@GabrielMartinez-ez9ue
@GabrielMartinez-ez9ue 2 жыл бұрын
@@RicardoGuillen if you know RTK, stick to that one and learn it well. Its great
@aravindsanjeev4150
@aravindsanjeev4150 2 жыл бұрын
Who wants to steal his intro bgm?
@Pareshbpatel
@Pareshbpatel 2 жыл бұрын
Great Tutorial on four ways to fetch data in React. Thanks, Pedro {2022-06-14}, {2023-09-06}
@andreyokhrimenko2271
@andreyokhrimenko2271 2 жыл бұрын
const { isLoading, error, data, isFetching } = useQuery(["dog"], () => axios .get("random.dog/woof.json") .then((res) => res.data) ); This is right way
Testing In React Tutorial - Jest and React Testing Library
21:28
Ozoda - Alamlar (Official Video 2023)
6:22
Ozoda Official
Рет қаралды 10 МЛН
Counter-Strike 2 - Новый кс. Cтарый я
13:10
Marmok
Рет қаралды 2,8 МЛН
ReactJS Course [7] - How To Fetch Data From an API in React
30:20
My Favorite Way to Fetch Data in React
16:28
Josh tried coding
Рет қаралды 72 М.
Why I avoid useEffect For API Calls and use React Query instead
17:45
Fetch API Introduction
30:54
Traversy Media
Рет қаралды 503 М.
All The JavaScript You Need To Know For React
28:00
PedroTech
Рет қаралды 671 М.
4 React Best Practices That Will Make You A PRO
18:12
PedroTech
Рет қаралды 146 М.
React Redux Tutorial For Beginners | Redux Toolkit Tutorial 2021
53:26
React Hooks Course - All React Hooks Explained
1:26:21
PedroTech
Рет қаралды 1,1 МЛН
Ozoda - Alamlar (Official Video 2023)
6:22
Ozoda Official
Рет қаралды 10 МЛН