Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Fetching Data with the Fetch API

Christopher Stuart
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Christopher Stuart
Full Stack JavaScript Techdegree Graduate 27,771 Points

ResponseData?

Can you just help understand one thing? At around 5:50, when you are creating the promises, the json data response gets turned into responseData--is that a name that you are creating or some sort of set named variable? Just a bit confused as to how it all comes together. Thanks

2 Answers

Zack Lee
PLUS
Zack Lee
Courses Plus Student 17,662 Points

responseData is a variable name, its just a container for the response.

he is using the ES6 arrow syntax for declaring a function. thus he he writes:

.then(responseData => {
   this.setState({gifs: responseData.data});
}

responseData is the function parameter and is passed the response that is being piped down the line, he just mutates the variable name into responseData so he can access different parts of the object, in this case the data object.