How to FETCH data from an API using JavaScript ↩️

  Рет қаралды 82,226

Bro Code

Bro Code

Күн бұрын

#javascript #utorial #course
00:00:00 fetch
00:06:29 async/await
00:08:55 project
// fetch = Function used for making HTTP requests to fetch resources.
// (JSON style data, images, files)
// Simplifies asynchronous data fetching in JavaScript and
// used for interacting with APIs to retrieve and send
// data asynchronously over the web.
// fetch(url, {options})
async function fetchData(){
try{
const pokemonName = document.getElementById("pokemonName").value.toLowerCase();
const response = await fetch(`pokeapi.co/api/v2/pokemon/${pokemonName}`);
if(!response.ok){
throw new Error("Could not fetch resource");
}
const data = await response.json();
const pokemonSprite = data.sprites.front_default;
const imgElement = document.getElementById("pokemonSprite");
imgElement.src = pokemonSprite;
imgElement.style.display = "block";
}
catch(error){
console.error(error);
}
}

Пікірлер: 83
@BroCodez
@BroCodez 5 ай бұрын
// fetch = Function used for making HTTP requests to fetch resources. // (JSON style data, images, files) // Simplifies asynchronous data fetching in JavaScript and // used for interacting with APIs to retrieve and send // data asynchronously over the web. // fetch(url, {options}) async function fetchData(){ try{ const pokemonName = document.getElementById("pokemonName").value.toLowerCase(); const response = await fetch(`pokeapi.co/api/v2/pokemon/${pokemonName}`); if(!response.ok){ throw new Error("Could not fetch resource"); } const data = await response.json(); const pokemonSprite = data.sprites.front_default; const imgElement = document.getElementById("pokemonSprite"); imgElement.src = pokemonSprite; imgElement.style.display = "block"; } catch(error){ console.error(error); } } Document Fetch Pokemon
@talebmine6562
@talebmine6562 Ай бұрын
Thanks, can you help me? I want the code to give me the logo
@Smurfis
@Smurfis 2 күн бұрын
I learn by using fun projects perhaps you could teach us how to make a little button based two player react game with this or something bro?
@Smurfis
@Smurfis 2 күн бұрын
Have always loved your videos thanks for this one particularly cos it’s exactly how I learn constants down, if not statement down variables being called down it’s sick thank you
@vaibhavagarwal1479
@vaibhavagarwal1479 Күн бұрын
Alternative Title :- Bro Code flexing his knowledge about pokemon's.
@yassinezammouri2955
@yassinezammouri2955 5 ай бұрын
Not only a progammer but also a pokemon fan.
@Th3Coder
@Th3Coder 4 ай бұрын
Same 🙂
@alternate_fantasy
@alternate_fantasy Ай бұрын
So what ?
@diegocamacho6060
@diegocamacho6060 Ай бұрын
@@alternate_fantasy ur mom
@alternate_fantasy
@alternate_fantasy Ай бұрын
@@diegocamacho6060 dont be sad kid :( im sorry for your life
@diegocamacho6060
@diegocamacho6060 Ай бұрын
@@alternate_fantasy ur mom
@user-rw4cj8hp1p
@user-rw4cj8hp1p 4 ай бұрын
From the buttom of my heart, and on behalf of everyone. i would like to thank you so much bro….. been struggling for months with this!!!😭❤️🙏🏾. Hoping to receive a reactJS one. Once again, thank you.
@alextruong1826
@alextruong1826 Ай бұрын
thank you for your video
@ay111nbg6
@ay111nbg6 8 күн бұрын
well said , i feel the same .
@abinayag4050
@abinayag4050 4 ай бұрын
in my bottom of the heart i really appreciate you. here lot of middle class student like me. your tutorial helped me alot without any fee. thanks keep going. i expected more tutorial from you😇😇😇😇
@JorgeHernandez-fo5kl
@JorgeHernandez-fo5kl 5 ай бұрын
i really enjoy all of your videos bro, you helped me a lot with this course, thank you! Psd: lucario is my fav pokemon
@RJ100
@RJ100 Ай бұрын
bro you're a legend. thank you for making code easier to learn.
@larvey_
@larvey_ 4 күн бұрын
I really thank you for your on-point tutorial really helping me advance my lil skills
@QuadriCSGO
@QuadriCSGO 4 ай бұрын
amazing tutorial man thanks
@muhammadshazeel567
@muhammadshazeel567 2 ай бұрын
i watch many tutorials on this topic but didn't understand it thanks for your video now i am finally understand it
@eusoumateusrocha
@eusoumateusrocha 3 ай бұрын
THIS IS THE BEST TUTORIAL IN KZbin ABOUT THIS. And my favorite pokemon is cyndaquil so when you said Typhlosion I was like whaaaaaaaaaaaaat! What are the odds? hahaha
@moeyk97
@moeyk97 3 ай бұрын
Amazing tutorial I’m gonna try this, style it nicely and flex on my class lmaooo
@Vincent_12770
@Vincent_12770 5 ай бұрын
this isn't included in your full Javascript course but i appreciate your efforts for doing it seperate
@TheBlueDude71
@TheBlueDude71 5 ай бұрын
His full Javascript course was made awhile ago, this is a new updated version of that course.
@vallunacoder.wecodetogether
@vallunacoder.wecodetogether 4 ай бұрын
Bro I made it 🤩🤩🤸‍♀🤸‍♀, the think is I just want to keep watching your videos. I thought I would never understand Java script.Hopefully this year I'm going to be able to make it! Send you a hug!
@valenciawalker6498
@valenciawalker6498 2 ай бұрын
Thank you very helpful.
@4soulsz
@4soulsz 5 ай бұрын
PERFECT TIMINGGGG THANK YOUUUUUU
@shafiulAlamShafi
@shafiulAlamShafi 4 ай бұрын
Super helpful
@lounes03b99
@lounes03b99 Ай бұрын
thank U to much Mr.Pokemon🔥❤‍🔥
@lakivicsa
@lakivicsa 3 ай бұрын
Thank you!
@haniehsolatpour8945
@haniehsolatpour8945 25 күн бұрын
So nice
@danielwolks8494
@danielwolks8494 5 күн бұрын
This was a better explanation of fetch then the shit they have on codecademy
@addyjaime465
@addyjaime465 Ай бұрын
This guy is a legend
@ajayxoxo
@ajayxoxo 5 ай бұрын
the things i need right on time 😊😊
@nopass6247
@nopass6247 5 ай бұрын
awesome, thanks bro 💕
@erialgumacoisa
@erialgumacoisa 4 ай бұрын
Thanks Bro
@fume6970
@fume6970 3 ай бұрын
The broest Bro I've ever had
@drewxx8527
@drewxx8527 5 ай бұрын
To be honest I was about to look for JavaScript form, about fetching and yes good counter I found this video xD
@programmated_brian
@programmated_brian 5 ай бұрын
loved the content man.
@gibbaren2552
@gibbaren2552 5 ай бұрын
Keep the good work up! It would be so appreciated if you did a beginner course on Rust all love
@muhammadyousaf2876
@muhammadyousaf2876 3 ай бұрын
thank you alot
@HuracanSeneca
@HuracanSeneca 5 ай бұрын
If she aint into me like he is into Typhlosion, I don’t want it!
@G.R.B.000
@G.R.B.000 5 ай бұрын
I LOVE YOU BRO CODE 🤩🤩🤩
@user-fs5np2et9g
@user-fs5np2et9g 5 ай бұрын
it was amazing
@leo..81777
@leo..81777 16 күн бұрын
👍👍👍
@regilearn2138
@regilearn2138 5 күн бұрын
if you can please do axios video also and how to handle express error objects meaningful status code error massages in real world app
@marouanebr409
@marouanebr409 2 ай бұрын
👍👍👍👍
@kyleshivers
@kyleshivers 5 ай бұрын
I wish I found Bro Code earlier in my ‘teaching myself to code’ journey
@user-mk2md9pu5m
@user-mk2md9pu5m 5 ай бұрын
Cool
@ghost.-.1290
@ghost.-.1290 5 ай бұрын
cool
@EuBrasileiro
@EuBrasileiro 5 ай бұрын
Please teach us lua in 2024!!! thanks for your content
@doronfeldman5152
@doronfeldman5152 5 ай бұрын
Hi bro, are you going to do a go course in the future?
@user-jd2tt1vx3s
@user-jd2tt1vx3s 5 ай бұрын
bro please do php crud operation video please make as soon as possible
@minh355
@minh355 Ай бұрын
For the first part, are the html and css files empty? I would assume so, but then how do you run JS in the console
@feelthesurge1003
@feelthesurge1003 5 ай бұрын
hello bro will their be any more videos on React JS?
@MiriamGordilloChavez
@MiriamGordilloChavez 2 ай бұрын
Question: what if we would not prefer to use async and await? how do we display the image with the fetch?
@2ameridiem
@2ameridiem 3 ай бұрын
should we not add an else block after checking response.ok property?
@anonym-6114
@anonym-6114 5 ай бұрын
Hey Bro, this question has actually nothing to do with this video but I’ve got a project where I have to implement the best move of the computer in the game TicTacToe. I just started to learn java but that’s quite hard. Do you have some tips for me? The computer has to try to defeat me and block me by placing the symbol to places wherever I could win. I hope that you will answer. Hava a nice day.
@ofekcohen6559
@ofekcohen6559 5 ай бұрын
You will make node is course?
@parikshitkolhe3295
@parikshitkolhe3295 2 ай бұрын
Oh my god....what were the chances....even typhlosion is my favourite pokemon...
@sr.pinheiro6386
@sr.pinheiro6386 5 ай бұрын
hey, can u do a ruby course ? pls
@weemarb
@weemarb 4 ай бұрын
my favorite pokemon is breloom I like using him to kidnap other pokemon
@MjRaj-hx2cu
@MjRaj-hx2cu 5 ай бұрын
This comment was automated
@maxknight8542
@maxknight8542 5 ай бұрын
are you able to teach php and sql
@user-vl9nt6mo9s
@user-vl9nt6mo9s 5 ай бұрын
Dragonite :D
@l213dhanesh3
@l213dhanesh3 5 ай бұрын
Code bro react bro.... My life bro.... My heart bro.... Plz bro do bro......
@erialgumacoisa
@erialgumacoisa 4 ай бұрын
NodeJS course pls
@harbirdhillon8195
@harbirdhillon8195 19 күн бұрын
Favorite Pokemon: Lugia
@zyntaXmods
@zyntaXmods 4 ай бұрын
How can i access object in an api and display on html I'm getting type error 😢
@eagledeluxe826
@eagledeluxe826 5 ай бұрын
Make on lua pls
@manueljoseph3528
@manueljoseph3528 Ай бұрын
is it possible to do sorting
@codeJourneyGuides
@codeJourneyGuides 2 ай бұрын
SpongeBob is still not a Pokemon lol 😂
@gamingwithyoungtrouble
@gamingwithyoungtrouble 5 ай бұрын
Do python next😢
@talebmine6562
@talebmine6562 Ай бұрын
I wont text generating logo with AI
@alternate_fantasy
@alternate_fantasy Ай бұрын
Quite not fair for a very basic and general video got such views.
@Mr-MITRA
@Mr-MITRA 2 ай бұрын
from today pikachu
@KiNGgamer-km4zi
@KiNGgamer-km4zi 5 ай бұрын
Sir bro node js please
@capslock3250
@capslock3250 5 ай бұрын
Kotlin or Golang course please.
@kichuofficial8887
@kichuofficial8887 3 ай бұрын
charizard
@marouanebr409
@marouanebr409 2 ай бұрын
(y) (y)
Build a JavaScript WEATHER APP in 30+ minutes! ☀️
38:40
Bro Code
Рет қаралды 30 М.
What are JavaScript PROMISES? 🤞
12:37
Bro Code
Рет қаралды 36 М.
Indian sharing by Secret Vlog #shorts
00:13
Secret Vlog
Рет қаралды 59 МЛН
Why You Should Always Help Others ❤️
00:40
Alan Chikin Chow
Рет қаралды 10 МЛН
ReactJS Course [7] - How To Fetch Data From an API in React
30:20
40 APIs Every Developer Should Use (in 12 minutes)
12:23
Coding with Lewis
Рет қаралды 265 М.
ASMR Programming: Dark/Light Toggle | Pure CSS
5:33
Codetive ASMR
Рет қаралды 14 М.
Callbacks, Promises, Async Await | JavaScript Fetch API Explained
1:05:05
Learn JSON in 10 Minutes
12:00
Web Dev Simplified
Рет қаралды 3,1 МЛН
GET Data from API & Display in HTML with JavaScript Fetch API
5:50
Let's code a beginner's Python BANK PROGRAM 💰
15:01
Bro Code
Рет қаралды 14 М.
ASMR Programming - Weather App With Javascript - No Talking
20:30
AsmrProg
Рет қаралды 2,6 МЛН
Learn Fetch API In 6 Minutes
6:35
Web Dev Simplified
Рет қаралды 1,2 МЛН