How to FETCH data from an API using JavaScript ↩️

preview_player
Показать описание
#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{

throw new Error("Could not fetch resource");
}

}
catch(error){
}
}
Рекомендации по теме
Комментарии
Автор

// 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 =

if(!response.ok){
throw new Error("Could not fetch resource");
}

const data = await response.json();
const pokemonSprite = data.sprites.front_default;
const imgElement =

imgElement.src = pokemonSprite;
imgElement.style.display = "block";
}
catch(error){
console.error(error);
}
}

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>

<input type="text" id="pokemonName" placeholder="Enter Pokemon name">
<button onclick="fetchData()">Fetch Pokemon</button><br>

<img src="" alt="Pokemon Sprite" id="pokemonSprite" style="display: none">

<script src="index.js"></script>
</body>
</html>

BroCodez
Автор

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😇😇😇😇

abinayag
Автор

bro you're a legend. thank you for making code easier to learn.

RJ
Автор

I really enjoy the way you explain how you are writing the code and why. Very informative and you make it intuitive. Great work!

NiceChange
Автор

thank you for your video <3 It is much easier to follow than other videos and I'm now confident in FETCH thanks to your clear instructions yet short enough to catch!!!

alextruong
Автор

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.

rwcjhpp
Автор

i really enjoy all of your videos bro, you helped me a lot with this course, thank you!
Psd: lucario is my fav pokemon

JorgeHernandez-fokl
Автор

I really thank you for your on-point tutorial really helping me advance my lil skills

larvey_
Автор

definitely the best explanation I've ever watch

emir-mubs
Автор

i watch many tutorials on this topic but didn't understand it thanks for your video now i am finally understand it

muhammadshazeel
Автор

THIS IS THE BEST TUTORIAL IN YOUTUBE ABOUT THIS. And my favorite pokemon is cyndaquil so when you said Typhlosion I was like What are the odds? hahaha

eusoumateusrocha
Автор

thanks, this video was super useful 😀

faststudios
Автор

Not only a progammer but also a pokemon fan.

yassinezammouri
Автор

Amazing tutorial I’m gonna try this, style it nicely and flex on my class lmaooo

moeyk
Автор

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!

vallunacoder.wecodetogether
Автор

using the pokemon api was a good choice for a introduction to fetch

bekay
Автор

Keep the good work up!
It would be so appreciated if you did a beginner course on Rust
all love <3

gibbaren
Автор

To be honest I was about to look for JavaScript form, about fetching and yes good counter I found this video xD

drewxx
Автор

definitely geodude. Thanks for making this fun.

memeingthroughenglish
Автор

this isn't included in your full Javascript course but i appreciate your efforts for doing it seperate

Vincent_