Тёмный

How to get data from an API with Javascript 

Richard Oliver Bray
Подписаться 8 тыс.
Просмотров 29 тыс.
50% 1

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

Опубликовано:

 

2 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 32   
@leader6422
@leader6422 10 месяцев назад
Don't forget the try ctach block
@CodeWithRia
@CodeWithRia 11 месяцев назад
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 11 месяцев назад
Also fetching data from an API that doesn't have id or page param.
@richardbray
@richardbray 11 месяцев назад
Sure thing, I'll add it to the list
@sxuwrr
@sxuwrr 2 месяца назад
Axios will help brother
@Atomistry
@Atomistry 7 месяцев назад
This is really helpful but how do you display the data that has been returned by the api?
@richardbray
@richardbray 7 месяцев назад
Currently just logging it to the console but if you had a framework you could just display the data in a templating language
@thecodebear
@thecodebear Год назад
Nice video👍
@SingularityFe
@SingularityFe 4 месяца назад
Yup, this is what I've started doing at work
@zahreddinesoualem3213
@zahreddinesoualem3213 11 месяцев назад
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 11 месяцев назад
Hmmm, I'm not sure I understand. Why would you want to do that in the first place?
@zahreddinesoualem3213
@zahreddinesoualem3213 11 месяцев назад
Long story, anyway thanks for your response I found my way to the what I was looking for.
@richochet
@richochet 7 месяцев назад
Brilliant 👏🏼
@guywhoplayz6042
@guywhoplayz6042 4 месяца назад
Or just chain it with thens and a catch
@factcinemaaa
@factcinemaaa 6 месяцев назад
From India
@WidowSoundsNoCopyright
@WidowSoundsNoCopyright 10 месяцев назад
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 10 месяцев назад
What error are you getting?
@WidowSoundsNoCopyright
@WidowSoundsNoCopyright 10 месяцев назад
@@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.
@akashofficial5869
@akashofficial5869 9 месяцев назад
Gud🎉
@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
@No_one12351
@No_one12351 5 месяцев назад
Awesome information!
@rameshbabu-r6g
@rameshbabu-r6g 11 месяцев назад
bro if we want to print that data into document ? then how can we use ??
@richardbray
@richardbray 10 месяцев назад
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
@ahmedahmedx9600
@ahmedahmedx9600 7 месяцев назад
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 7 месяцев назад
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 7 месяцев назад
@richardbray yes I got it but not 100% 😅, so if you can do a video about that topic I'll be grateful 💙
@Omaxim1638
@Omaxim1638 10 месяцев назад
Pls do for C++
@conradhansen-quartey5053
@conradhansen-quartey5053 2 месяца назад
Explained well - thank you!
@richardbray
@richardbray Месяц назад
You're welcome!
@33v4.
@33v4. Год назад
when/how do you that you can fetch without using async await?
@richardbray
@richardbray Год назад
You can use the .then() method
Далее
Вопрос Ребром - Серго
43:16
Просмотров 1,5 млн
1.4: JSON - Working with Data and APIs in JavaScript
16:22
Using docker in unusual ways
12:58
Просмотров 451 тыс.
Using Python to Fetch API Data into CSV
5:24
Просмотров 32 тыс.
Always Check for the Hidden API when Web Scraping
11:50
40 APIs Every Developer Should Use (in 12 minutes)
12:23
Why Signals Are Better Than React Hooks
16:30
Просмотров 478 тыс.
Learn JSON in 10 Minutes
12:00
Просмотров 3,2 млн
Вопрос Ребром - Серго
43:16
Просмотров 1,5 млн