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 Building a Search Feature

Scott Saniuk
Scott Saniuk
87 Points

Trouble displaying image data - React giphy search tutorial

I am running into an issue with the giphy search tutorial. I am getting back gif data from the server, and can see the "images" field in the returned gifs. However when I try to display a url like "props.data.images.fixed_width.url", I am getting an error "cannot read property "fixed_width" of undefined. I've tried reading any of the subproperties of images at multiple points in the app, and I always get that error. It is very strange because I can read any of the base level elements, and if I spit out the images property, it shows all the additional subproperties I am looking for. I'm stumped and can't seem to get past this, and even more confused because when I'm not troubleshooting I have the code in there exactly as it is working in the tutorial...

jobbol
seal-mask
.a{fill-rule:evenodd;}techdegree
jobbol
Full Stack JavaScript Techdegree Student 16,610 Points

So the console log is telling you "props.data.images" has nothing in it.

Firing early

I'm assuming you're working with xhr. Are your images completely loaded before you begin looking at their properties? Console log when the load finishes, and again at the point of access. Access should occur after.

Data type

Is images of type object and not an array? Did you mean something like images[i].fixed_width.url?