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 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: