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

Trying to take the dog api challenge and switch to a public cat api for practice but got stuck. Any one can help?

The cat api isn't different for sure but on a basic level I just want to return a random cat picture and display

Here's my public git that I'm working off repo - https://github.com/mattdotroberts/treeh_catapp1/blob/gh-pages/js/app.js web page - https://mattdotroberts.github.io/treeh_catapp1/

You'll see all the dog displays are there for now and the public api is https://aws.random.cat/meow

2 Answers

Steven Parker
Steven Parker
231,007 Points

The API's are bit different. In particular, the dog service returns an object with the image URL in the key "message" along with a "status" key and value.

But the cat service returns an object with the image URL in the key "file" instead, and it has no "status" key.

Steven Parker
Steven Parker
231,007 Points

So you just need to change "message" to "file" where "randomImage" is being assigned on line 22.

If your original question has been answered, you can mark the question solved by choosing a "best answer".
And happy coding!

Cool. I'm struggling with working backwards to see where these differences are in the dog code. What would be the first thing you would do ?