From the course: Introduction to Web APIs
Unlock the full course today
Join today to access over 23,200 courses taught by industry experts.
Access data in the response - REST Tutorial
From the course: Introduction to Web APIs
Access data in the response
- [Instructor] Now that we're able to filter and sort response data, let's see how we access specific parts of the data. Let's click the dropdown arrow here next to our first product. This will open it up so we can see all the data for this one product. As we talked about previously, with JSON, we have our data displayed in key value pairs. So here we see the keys. ID, description, image, price, name, et cetera. Remembering that these products are objects, we access the keys or properties within the object using dot notation. As I said before, it helps me to think of dot notation to access properties in a response like finding a file on a computer. It's similar to a file path that digs through directories and sub directories to get to the information that we want. Instead of slashes, we use dots. So let's do that. Let's use dot notation to get only the description for the first item and print it to the console. After…
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)
-
-
-
-