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

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…

Contents