GET Data from API & Display in HTML with JavaScript Fetch API

  Рет қаралды 153,932

ByteGrad

ByteGrad

Күн бұрын

👉 NEW React & Next.js Course: bytegrad.com/courses/professi...
Hi, I'm Wesley. I'm a brand ambassador for Kinde (paid sponsorship).
👉 Add auth to your app FAST: bit.ly/3QOe1Bh
👉 NEW React & Next.js Course: bytegrad.com/courses/professi...
👉 Professional JavaScript Course: bytegrad.com/courses/professi...
👉 Professional CSS Course: bytegrad.com/courses/professi...
👉 Discord: all my courses have a private Discord where I actively participate
🔔 Email newsletter (BIG update soon): email.bytegrad.com
⏱️ Timestamps:
0:00 - Intro
0:44 - Get data with Fetch API (GET request)
3:07 - Display data by manipulating HTML / DOM with JavaScript
#fetchapi #fetch #fetchjavascript #javascript

Пікірлер: 87
@ysammo214
@ysammo214 11 ай бұрын
This is the video that finally made API's "click" for me. So concise and informative. Thankyou!
@abdulsaboor2004.
@abdulsaboor2004. 4 ай бұрын
I literally looked up entire YT, but couldn't find a single video that exactly teaches how to get and display data using API. Luv u ♥
@ustav_o
@ustav_o 4 ай бұрын
jesus that may be the best tutorial ive ever seen about this. in only 5 minutes we got everything we need and also some extra really usefull knowledge. respect
@AAustinBB231
@AAustinBB231 Жыл бұрын
subbed after one minute. concise, clear, and well explained.
@yeic7434
@yeic7434 6 ай бұрын
I never understood api's when they talked about them in college, now i have to work with them, so im doing some research and this 5 minute video made me understand them xD Thank bro keep it up!
@twizzy8783
@twizzy8783 4 ай бұрын
yeah this explained the fundamentals so well, im glad i didn’t watch the 3 hour videos instead
@Germane_5
@Germane_5 8 ай бұрын
Excellent video. Straight to the point. Kudos man.
@nadiasaveljevas9447
@nadiasaveljevas9447 11 ай бұрын
Thank you so much! Finally I have the API result in a multiple select in the HTML form!
@ogzombiebreakfast
@ogzombiebreakfast Жыл бұрын
Thank you! I've been trying to figure this out for a couple of days now.
@sampaglan
@sampaglan 6 ай бұрын
Very awesome video. Conscise and straingt to the point. Thamk's for saving my life after almost a week of trying and searching
@jamiedoig9568
@jamiedoig9568 Жыл бұрын
Great catalogue of videos rich with content! Thank you very much for the tips
@melissacouturier5644
@melissacouturier5644 Жыл бұрын
thank you for this video! was exactly what i was looking for
@-.-smile
@-.-smile Жыл бұрын
Thanks man. I was looking for this!
@t1910j
@t1910j Жыл бұрын
Eye opening! Thank you very much
@Habitual-Developer
@Habitual-Developer Жыл бұрын
Really a perfect explanation. Professional flow😊😊
@toastedclosure2770
@toastedclosure2770 Жыл бұрын
was looking for this! thank you
@DivyanshMaurya-1
@DivyanshMaurya-1 5 ай бұрын
Thanks bro, very nice and informative video
@jB_s
@jB_s 10 ай бұрын
This is a solid video. Thanks for the good work!
@webprogrammingtutorials-alo69
@webprogrammingtutorials-alo69 Жыл бұрын
Very useful lesson. Thanks
@trooper3199
@trooper3199 6 ай бұрын
Thank you very much 🫡
@EgorKozjevnikov
@EgorKozjevnikov Жыл бұрын
Thank you very much for an informative video, helped to continue with a task
@tika6050
@tika6050 11 ай бұрын
Thanks for the tutorial sir. I appreciate it
@kennykenny6176
@kennykenny6176 5 ай бұрын
Thank you
@ramandamytv1193
@ramandamytv1193 Жыл бұрын
awesome vid! Thanks so much!
@kenzouframe
@kenzouframe 11 ай бұрын
YOU ARE A GOOD, MY KING, OMG This video solve my problem thanks my man
@lennertvangeert4249
@lennertvangeert4249 Жыл бұрын
You saved my life at school today
@aabirsabil4393
@aabirsabil4393 10 ай бұрын
Thank you for this awesome video
@yadavbhavesh6957
@yadavbhavesh6957 Жыл бұрын
amazing api video ever thank you bro for this amazing video
@GTOFFICIAL22
@GTOFFICIAL22 10 ай бұрын
Thank you so much man
@codewithravi8549
@codewithravi8549 Жыл бұрын
Thank you.
@sandeshjadhav7223
@sandeshjadhav7223 11 ай бұрын
thank you nice explanation
@ggbin8092
@ggbin8092 7 ай бұрын
hi, i'm looking for a way to store api data in a variable, so that i can reuse it later. i'm not sure if this is the right way people do.
@MrAgentjames
@MrAgentjames Жыл бұрын
Is there possibility to fetch data from ftp or local folder? Or on which sites can I automatically send files?
@tia_____1891
@tia_____1891 11 ай бұрын
Can I use a route in place of url . I want to fetch data from mongo db .
@myosotisalderson
@myosotisalderson Жыл бұрын
Hello :) thank you for your video, but there is a mistake, you should give a new variable and assign "Array.form(data), if you don't write this line, your code wont work. Thanks bro
@RonClarijs
@RonClarijs Жыл бұрын
I think replacing forEach with map is better. Of course 'join("")' it afterwards and inject it in ul html element afterwards
@joshuaoseiawuah1157
@joshuaoseiawuah1157 6 ай бұрын
that was what i was thinking too i have always love to use map on arrays
@kurtismelkisoft4309
@kurtismelkisoft4309 Жыл бұрын
What if I want to store this data in a variable and then use it later
@Ebube_dee
@Ebube_dee 5 ай бұрын
Please I have a question When do you use fetch api
@dimjim2365
@dimjim2365 5 ай бұрын
Great video. I did have a problem with line 22. Had to change to "" +user.name+ "" to get it to work. Otherwise it just quoted the line. I guess this is a browser difference or something.--- Update. Okay so I was using the wrong key. I thought it was the single quote key instead of the back tick or whatever you call it. Me Bad!
@souravjoshishorts7199
@souravjoshishorts7199 5 ай бұрын
That's why he used $ sign for back tick
@PaulPetrutoni
@PaulPetrutoni Жыл бұрын
Thanks!
@ByteGrad
@ByteGrad Жыл бұрын
Appreciate the Super Thanks! Thanks
@mahipalsingh816
@mahipalsingh816 11 ай бұрын
gd one
@niyanth_reddy
@niyanth_reddy Жыл бұрын
Is it good to fetch data from api and save it in database for a page that we load several times or use api directly?
@ByteGrad
@ByteGrad Жыл бұрын
It’s a lot more work with database
@A--ti7vc
@A--ti7vc Жыл бұрын
bro I've been asking a question for a year, which made me confusing about my learning skills, or my brain IQ let me say, the question is : can I use the fetched data from the API outside the promise? this question is not just mine, there are many beginners have this questions, and had this question, if not all the leaners had asked this question yet, the main here is if u can do a video about that it will be really helpful, the answer with yes u can or not u can't will be helpful not just if there is a possibility, and thanks for reading this
@thedarkshadoww9711
@thedarkshadoww9711 Жыл бұрын
Why not create a variable outside the scope of the fetch function and then when you receive the data just save it that variable. Since that variable is outside the fetch function, you can use it's data outside of the function.
@rizkijanuar205
@rizkijanuar205 Жыл бұрын
Thanks a lot sir 🙏, is there any website reference to learn the ( ` ) symbol ? I'm inserting the wrong symbol ( ' ) when declare "markup" variable on 3:52 😄
@kvkcreations2313
@kvkcreations2313 11 ай бұрын
it is backtick available in keyboard below escape button
@kvkcreations2313
@kvkcreations2313 11 ай бұрын
backtick ``
@rizkijanuar205
@rizkijanuar205 11 ай бұрын
@@kvkcreations2313 Thank you so much sir 🙏
@souravjoshishorts7199
@souravjoshishorts7199 5 ай бұрын
Its template literal
@lycanunleashed
@lycanunleashed Жыл бұрын
nice video but there is one thing i dont understand.. suppose we used async await to get the data.. how can we then use the same data in lets say 10 other functions without having to fetch the same data over and over again in all the functinos
@ByteGrad
@ByteGrad Жыл бұрын
Sorry too busy to give you a complete / good answer. You would just assign the data to an outside variable. I highly recommend to go through my Professional JavaScript course so these things become easy.
@alamond3318
@alamond3318 Жыл бұрын
You could cache the data. You can watch a tutorial on caching.
@larryjasontueno9016
@larryjasontueno9016 8 ай бұрын
Why none on these fetch tutorials explain how they create their api? Please
@neozoid7009
@neozoid7009 Жыл бұрын
Can I get Any Data from Any Website from this Method??
@rohithn8811
@rohithn8811 10 ай бұрын
Can we display a specific data using the id value??
@ByteGrad
@ByteGrad 10 ай бұрын
You can fetch any data you like, yes
@ranjitkr87
@ranjitkr87 Жыл бұрын
Is this not compatible on webflow ? because it is showing ${user.name} instead of actual user name for each user
@ByteGrad
@ByteGrad Жыл бұрын
Interesting use case, I don’t know how to do this in Webflow
@ranjitkr87
@ranjitkr87 Жыл бұрын
@@ByteGrad Completely my mistake. Your solution works like charm. I used ' instead of `. Thanks a lot
@aceguevarra2893
@aceguevarra2893 Жыл бұрын
can i use append instead of insertAdjacentHTML?
@ByteGrad
@ByteGrad Жыл бұрын
Better to use insertAdjacentHTML if you have a string representing HTML. We want to insert a string that will be parsed as HTML so we have to use insertAdjacentHTML, if you use append the string will simply be text and if you use appendChild you have to create an HTML-element / 'node' to insert first.
@aceguevarra2893
@aceguevarra2893 Жыл бұрын
@@ByteGrad ohhh okay understood, thanks ♥️
@ric190720
@ric190720 Жыл бұрын
data already array, but when i add the "data.foreach...." is said is not a function
@ByteGrad
@ByteGrad Жыл бұрын
It’s forEach (with capital)
@somarble
@somarble Жыл бұрын
thanks but next time provide a link to API
@sanchitsharma2899
@sanchitsharma2899 Жыл бұрын
Uncaught (in promise) TypeError: Cannot set properties of null (setting 'innerHTML') Its showing this error even I tried put the script tag below table tag but not working.
@ByteGrad
@ByteGrad Жыл бұрын
Seems like you didn’t select the HTML-element properly
@sanchitsharma2899
@sanchitsharma2899 Жыл бұрын
@@ByteGrad Actually I am doing it for table(showing Uncaught (in promise) TypeError: Cannot set properties of null (setting 'innerHTML'))- Can you help with this? ---------------------------------------------------------------- id it titile body async function fetchApi(){ let result = await fetch("jsonplaceholder.typicode.com/posts"); result = await result.json(); console.warn(result); document.getElementById(data).innerHTML = result.map((data)=>( ` ${data.body} ${data.it} ${data.body} ${data.userId} ` )).join(); } fetchApi();
@BigWickVic
@BigWickVic Жыл бұрын
how would I fetch only the data of an object thats not an array?
@BigWickVic
@BigWickVic Жыл бұрын
subscribed by the way
@ByteGrad
@ByteGrad Жыл бұрын
You would get the data the exact same way, but just handle it differently once you get it.
@ricardodelacrvz1400
@ricardodelacrvz1400 Жыл бұрын
tried doing this for the pokemon api in my bootcamp it doesnt work
@ByteGrad
@ByteGrad Жыл бұрын
Any error messages?
@Racine14
@Racine14 Жыл бұрын
But for I get an error said: data.forEach is not a function.
@ByteGrad
@ByteGrad Жыл бұрын
Check if data is actually an array (console.log it)
@Racine14
@Racine14 Жыл бұрын
@@ByteGrad Thank you dear but I got where the error cames from. Within my foreach loop : data.ArrayName.forEach
@garyoak4175
@garyoak4175 Жыл бұрын
data.forEach is not a function (console error)
@ByteGrad
@ByteGrad Жыл бұрын
Check if data is actually an array: console.log(data) and see what you get
@Mr.Fri3nd
@Mr.Fri3nd Жыл бұрын
index.htm:13 Uncaught (in promise) TypeError: data.forEach is not a function
@ByteGrad
@ByteGrad Жыл бұрын
Try console.log(data) to see if you actually have an array
@user-ne6cj9wi7e
@user-ne6cj9wi7e Жыл бұрын
Ik hoor Nederlands
@ByteGrad
@ByteGrad Жыл бұрын
Hi, mastering JavaScript is critical if you want to be a modern, professional developer: www.udemy.com/course/professional-javascript-course/?referralCode=0C1D5752923168BC87C2 Also, if you are a front-end developer then mastering CSS (including Flexbox, CSS Grid, etc.) is equally important: www.udemy.com/course/professional-css/?referralCode=4C3C08E82629E6B15752
@user-ku3zt3nd6l
@user-ku3zt3nd6l 10 ай бұрын
source code ?
POST Form Data With JavaScript Fetch API
9:52
ByteGrad
Рет қаралды 23 М.
Fetch API with Async/Await (GET, POST, PUT, DELETE)
14:55
ByteGrad
Рет қаралды 22 М.
1 класс vs 11 класс (неаккуратность)
01:00
КАКОЙ ВАШ ЛЮБИМЫЙ ЦВЕТ?😍 #game #shorts
00:17
Hot Ball ASMR #asmr #asmrsounds #satisfying #relaxing #satisfyingvideo
00:19
Oddly Satisfying
Рет қаралды 17 МЛН
GET Data from API & Display in HTML using JavaScript Fetch API
17:23
Web Developer Roadmap (2024) - Everything is Changing
25:02
ByteGrad
Рет қаралды 265 М.
How to create a CSS navigation bar in 6 minutes! 🧭
6:28
Bro Code
Рет қаралды 209 М.
Display JSON data in HTML table using JavaScript
4:27
Digital Fox
Рет қаралды 89 М.
How to FETCH data from an API using JavaScript ↩️
14:17
Bro Code
Рет қаралды 82 М.
1.4: JSON - Working with Data and APIs in JavaScript
16:22
The Coding Train
Рет қаралды 639 М.
Learn CSS Subgrid in 14 minutes
14:19
Slaying The Dragon
Рет қаралды 50 М.
I built the same app 10 times // Which JS Framework is best?
21:58
Fireship
Рет қаралды 2,4 МЛН
Mi primera placa con dios
0:12
Eyal mewing
Рет қаралды 525 М.
Carregando telefone com carregador cortado
1:01
Andcarli
Рет қаралды 2,2 МЛН
Main filter..
0:15
CikoYt
Рет қаралды 610 М.
Не обзор DJI Osmo Pocket 3 Creator Combo
1:00
superfirsthero
Рет қаралды 1,3 МЛН
iphone fold ? #spongebob #spongebobsquarepants
0:15
Si pamer 😏
Рет қаралды 687 М.
Где раздвижные смартфоны ?
0:49
Не шарю!
Рет қаралды 393 М.