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.

General Discussion Displaying the Content

Ryan King
Ryan King
5,068 Points

Whats wrong???

i dont get the options or the name of the breeds below my image.

fetch('https://dog.ceo/api/breeds/list') .then(response => response.json) .then(data => generateOptions(data.message))

fetch('https://dog.ceo/api/breeds/image/random') .then(response => response.json()) .then(data => generateImage(data.message))

// ------------------------------------------ // HELPER FUNCTIONS // ------------------------------------------

function generateOptions(data) { const options = data.map(item => <option value='${item}'>${item}</option> ); select.innerHTML = options; }

function generateImage(data) { const html = <img src = '${data}' alt> <p>Click to view images of ${select.value}s</p> ; card.innerHTML = html }

1 Answer

Brandon White
.a{fill-rule:evenodd;}techdegree seal-36
Brandon White
Treehouse Moderator

Hi Ryan King,

The solution to your bug may be as simple as you’re attempting to use template literals without surrounding them in back tics. ` 👈🏾 This character needs to be placed before and after the following syntax: ${}.

Make that correction and things may work as you’re expecting them to. If not, I would question whether the argument you’re passing into the function is what you’re intending to pass into them. I don’t know because I don’t know the structure of the response being returned from the server. But , for instance, you’re calling map on the argument passed into the generateOptions, so that argument needs to be an array. So if the value of data.message isn’t an array, then your code may not function as intended. But again, that part may be perfect. Just wanted to add it as a potential option in case my first suggestion doesn’t act as a complete solution.