No video

How to get data from an API with Javascript

  Рет қаралды 26,051

Richard Oliver Bray

Richard Oliver Bray

Күн бұрын

#javascript #shorts #code #webdevelopment #webdev #fetch #api #data #asyncawait #tipsandtricks #beginner #typescript

Пікірлер: 32
@leader6422
@leader6422 9 ай бұрын
Don't forget the try ctach block
@CodeWithRia
@CodeWithRia 10 ай бұрын
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 10 ай бұрын
Also fetching data from an API that doesn't have id or page param.
@richardbray
@richardbray 10 ай бұрын
Sure thing, I'll add it to the list
@thecodebear
@thecodebear Жыл бұрын
Nice video👍
@conradhansen-quartey5053
@conradhansen-quartey5053 Ай бұрын
Explained well - thank you!
@richardbray
@richardbray 18 күн бұрын
You're welcome!
@richochet
@richochet 6 ай бұрын
Brilliant 👏🏼
@No_one12351
@No_one12351 4 ай бұрын
Awesome information!
@akashofficial5869
@akashofficial5869 8 ай бұрын
Gud🎉
@SingularityFe
@SingularityFe 3 ай бұрын
Yup, this is what I've started doing at work
@sxuwrr
@sxuwrr Ай бұрын
Axios will help brother
@Atomistry
@Atomistry 6 ай бұрын
This is really helpful but how do you display the data that has been returned by the api?
@richardbray
@richardbray 6 ай бұрын
Currently just logging it to the console but if you had a framework you could just display the data in a templating language
@factcinemaaa
@factcinemaaa 5 ай бұрын
From India
@guywhoplayz6042
@guywhoplayz6042 2 ай бұрын
Or just chain it with thens and a catch
@Omaxim1638
@Omaxim1638 9 ай бұрын
Pls do for C++
@zahreddinesoualem3213
@zahreddinesoualem3213 10 ай бұрын
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 10 ай бұрын
Hmmm, I'm not sure I understand. Why would you want to do that in the first place?
@zahreddinesoualem3213
@zahreddinesoualem3213 10 ай бұрын
Long story, anyway thanks for your response I found my way to the what I was looking for.
@WidowSoundsNoCopyright
@WidowSoundsNoCopyright 9 ай бұрын
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 9 ай бұрын
What error are you getting?
@WidowSoundsNoCopyright
@WidowSoundsNoCopyright 9 ай бұрын
@@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 6 ай бұрын
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 6 ай бұрын
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 6 ай бұрын
@richardbray yes I got it but not 100% 😅, so if you can do a video about that topic I'll be grateful 💙
@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
@user-xq5cg4jo4y
@user-xq5cg4jo4y 9 ай бұрын
bro if we want to print that data into document ? then how can we use ??
@richardbray
@richardbray 9 ай бұрын
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
@33v4.
@33v4. 11 ай бұрын
when/how do you that you can fetch without using async await?
@richardbray
@richardbray 11 ай бұрын
You can use the .then() method
Learn JSON in 10 Minutes
12:00
Web Dev Simplified
Рет қаралды 3,2 МЛН
How to FETCH data from an API using JavaScript ↩️
14:17
Bro Code
Рет қаралды 119 М.
WILL IT BURST?
00:31
Natan por Aí
Рет қаралды 15 МЛН
Fortunately, Ultraman protects me  #shorts #ultraman #ultramantiga #liveaction
00:10
1.4: JSON - Working with Data and APIs in JavaScript
16:22
The Coding Train
Рет қаралды 643 М.
Pydantic Tutorial • Solving Python's Biggest Problem
11:07
pixegami
Рет қаралды 265 М.
JavaScript Pro Tips - Code This, NOT That
12:37
Fireship
Рет қаралды 2,5 МЛН
Fetching Data in React - Complete Tutorial
29:10
Cosden Solutions
Рет қаралды 113 М.
ReactJS Course [7] - How To Fetch Data From an API in React
30:20
Master React JS in easy way
12:18
Nova Designs
Рет қаралды 63 М.
POST Form Data as JSON with Fetch API in JavaScript
9:25
ByteGrad
Рет қаралды 60 М.
JavaScript Fetch API - One Mistake I ALWAYS MAKE!
4:47
James Q Quick
Рет қаралды 24 М.
PROOF JavaScript is a Multi-Threaded language
8:21
Beyond Fireship
Рет қаралды 275 М.
WILL IT BURST?
00:31
Natan por Aí
Рет қаралды 15 МЛН