From the course: Introduction to Web APIs
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Use the response data in HTML - REST Tutorial
From the course: Introduction to Web APIs
Use the response data in HTML
- [Instructor] This is great. We're seeing how to get data from an API, and even how to filter the data and dig down into it. But likely we want to actually use the data on a webpage. So let's see how we can incorporate the API data into some HTML. Let's display the name of a product on the page. First, let's change our current codes that we're getting the product name instead of the description and print that to the console. So I'll change the variable from description to name. The property I want is not description but name, and then console.log name. Okay, the first thing I want to do is create an element in JavaScript. I'm going to call this element product. So var product, and that'll be equal to document.createElement to create an HTML element. And then the element that we want to create is going to be a list item. Now what I need to do is add some of the API data to this HTML element. So I'm going to type…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
API documentation2m 23s
-
(Locked)
Make a request to the API2m 36s
-
(Locked)
Filter the response with parameters3m 54s
-
(Locked)
Access data in the response2m 38s
-
(Locked)
Use the response data in HTML1m 47s
-
(Locked)
Loop through the response data4m 28s
-
(Locked)
Challenge: Display data on a webpage42s
-
(Locked)
Solution: Display data on a webpage1m 41s
-
(Locked)
-
-
-
-