Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript Create a Reusable Fetch Function

Only first image loads.

When I refresh or load the page the first random image appears, but if I click the card, or try to select a breed, I get a broken image on the page and an error 4404 not found message in the console.

https://w.trhou.se/fro5pcf7n7

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Jerome vanGaalen! You're doing well, and this all comes down to some punctuation. On line 44 of app.js you are using single quotes where you should be using backticks. So instead of it looking for the breed you selected it's literally searching for ${breed} instead of say Labrador.

Line 44 of app.js right now:

fetchData('https://dog.ceo/api/breed/${breed}/images/random')

But that should be:

// note the backticks instead of single quotes
fetchData(`https://dog.ceo/api/breed/${breed}/images/random`)

Hope this helps! :sparkles: