How to get data from an API with Javascript

  Рет қаралды 34,525

Richard Oliver Bray

Richard Oliver Bray

Күн бұрын

Пікірлер: 33
@thiagoflores9029
@thiagoflores9029 15 күн бұрын
Okey this is exactly what I needed. Concise direct and straight to the point. Love it
@CodeWithRia
@CodeWithRia Жыл бұрын
Thanks, I love this shorts you do where you explain key concept in JS or React simply for anyone to understand. They have been really helpful and understandable. Please keep doing them. Could you do some on using axios in react and also how to display data you fetch from an api on the browser. Thank You.
@CodeWithRia
@CodeWithRia Жыл бұрын
Also fetching data from an API that doesn't have id or page param.
@richardbray
@richardbray Жыл бұрын
Sure thing, I'll add it to the list
@leader6422
@leader6422 Жыл бұрын
Don't forget the try ctach block
@richochet
@richochet 10 ай бұрын
Brilliant 👏🏼
@thecodebear
@thecodebear Жыл бұрын
Nice video👍
@conradhansen-quartey5053
@conradhansen-quartey5053 5 ай бұрын
Explained well - thank you!
@richardbray
@richardbray 4 ай бұрын
You're welcome!
@akashofficial5869
@akashofficial5869 Жыл бұрын
Gud🎉
@No_one12351
@No_one12351 8 ай бұрын
Awesome information!
@Atomistry
@Atomistry 10 ай бұрын
This is really helpful but how do you display the data that has been returned by the api?
@richardbray
@richardbray 10 ай бұрын
Currently just logging it to the console but if you had a framework you could just display the data in a templating language
@SingularityFe
@SingularityFe 7 ай бұрын
Yup, this is what I've started doing at work
@sxuwrr
@sxuwrr 5 ай бұрын
Axios will help brother
@zahreddinesoualem3213
@zahreddinesoualem3213 Жыл бұрын
Sir, I am golang developer, I dound myself forced to build a website with react and go, can you give quick tip how to access each element from json individually?
@richardbray
@richardbray Жыл бұрын
Hmmm, I'm not sure I understand. Why would you want to do that in the first place?
@zahreddinesoualem3213
@zahreddinesoualem3213 Жыл бұрын
Long story, anyway thanks for your response I found my way to the what I was looking for.
@Omaxim1638
@Omaxim1638 Жыл бұрын
Pls do for C++
@guywhoplayz6042
@guywhoplayz6042 6 ай бұрын
Or just chain it with thens and a catch
@WidowSoundsNoCopyright
@WidowSoundsNoCopyright Жыл бұрын
how do i access a random 3rd party api? For me, nothing is happening when I try to fetch from it even though I did what you did.
@richardbray
@richardbray Жыл бұрын
What error are you getting?
@WidowSoundsNoCopyright
@WidowSoundsNoCopyright Жыл бұрын
@@richardbray im not getting any error. Its just either printing nothing to the console (even though I'm printing the data and) or it just says undefined. Im using a pretty unpopular API so I don't know if that's the reason or not. But it should work.
@ahmedahmedx9600
@ahmedahmedx9600 10 ай бұрын
But what if i dont want js to run the next line before getting data first ? Is there a way to block js in fetch line
@richardbray
@richardbray 10 ай бұрын
You'd have to put the code you want to run next in the promise resolve section, so the then method or create a promise with the code and await it, if that makes sense. Happy to make a video if it doesn't.
@ahmedahmedx9600
@ahmedahmedx9600 10 ай бұрын
@richardbray yes I got it but not 100% 😅, so if you can do a video about that topic I'll be grateful 💙
@rameshbabu-r6g
@rameshbabu-r6g Жыл бұрын
bro if we want to print that data into document ? then how can we use ??
@richardbray
@richardbray Жыл бұрын
You can create an element with JavaScript and use innerHTML or innerText to add data to it. Or you could use a framework like React
@kseperepere505
@kseperepere505 Жыл бұрын
How different is it from getting data from maybe a Github repo
@richardbray
@richardbray Жыл бұрын
It's not common for data to be kept in a github repo. If you wanted to get data from the ChatGPT api, you would need an api key which isn't available via github
@factcinemaaa
@factcinemaaa 9 ай бұрын
From India
@33v4.
@33v4. Жыл бұрын
when/how do you that you can fetch without using async await?
@richardbray
@richardbray Жыл бұрын
You can use the .then() method
How to FETCH data from an API using JavaScript ↩️
14:17
Bro Code
Рет қаралды 170 М.
Master Media Queries And Responsive CSS Web Design Like a Chameleon!
9:44
Slaying The Dragon
Рет қаралды 403 М.
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
JavaScript Visualized - Event Loop, Web APIs, (Micro)task Queue
12:35
GET Data from API & Display in HTML with JavaScript Fetch API
5:50
The Dome Paradox: A Loophole in Newton's Laws
22:59
Up and Atom
Рет қаралды 796 М.
Fetch vs. Axios in 1 minute
1:25
onjsdev
Рет қаралды 1,4 М.
Learn Fetch API In 6 Minutes
6:35
Web Dev Simplified
Рет қаралды 1,3 МЛН
What is mathematical thinking actually like?
9:44
Benjamin Keep, PhD, JD
Рет қаралды 10 М.
1.4: JSON - Working with Data and APIs in JavaScript
16:22
The Coding Train
Рет қаралды 647 М.