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

Tracy Excell
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tracy Excell
Front End Web Development Techdegree Graduate 15,333 Points

Spotify API to get information

Hello,

I have created a function:

 ```function displayAlbums(data){
var html = '<ul>';
$.each(data.tracks, function(i,eachAlbum){
  html += '<li class="albumImage">';
  html += '<img src="' + eachAlbum.album.images[0].url + '">';
  html += '</li>';
}); // closes each
html += '</ul>';
$("#albumImages").html(html);
 }//closes displayAlbums function

 $.getJSON(spotifyURL, albumData, displayAlbums);

```});//closes click function

this access the album image for me off the spotify API. However I can not write the code correctly to access, for example the album title or artists name. This is what I have. I anyone can see where I am going wrong, it would be appreciated.

function albumInformation(data){

var infoHTML = '<ul id="data">';

$.each(data.tracks, function(i, track){
 infoHTML += '<li class="albumInfo">';
  infoHTML += '<p' + track.album.artists[0].name + '"></p>';
  infoHTML += '</li>';
}); // closes each

 infoHTML += '</ul>';

   $(overlay).append(infoHTML);
   } //closes albumInformation function

  $.getJSON(spotifyURL, albumData, albumInformation);



 code example from the API 

    {
  "tracks" : [ {
"album" : {
  "album_type" : "album",
  "artists" : [ {
    "external_urls" : {
      "spotify" : "https://open.spotify.com/artist/3WrFJ7ztbogyGnTHbHJFl2"
    },
    "href" : "https://api.spotify.com/v1/artists/3WrFJ7ztbogyGnTHbHJFl2",
    "id" : "3WrFJ7ztbogyGnTHbHJFl2",
    "name" : "The Beatles",
    "type" : "artist",
    "uri" : "spotify:artist:3WrFJ7ztbogyGnTHbHJFl2"
  } ],
  "available_markets" : [ "CA", "MX", "US" ],
  "external_urls" : {
    "spotify" : "https://open.spotify.com/album/0ETFjACtuP2ADo6LFhL6HN"
  },
  "href" : "https://api.spotify.com/v1/albums/0ETFjACtuP2ADo6LFhL6HN",
  "id" : "0ETFjACtuP2ADo6LFhL6HN",
  "images" : [ {
    "height" : 640,
    "url" : "https://i.scdn.co/image/c429243cd056974175abe72a3142d3dccffc166a",
    "width" : 640
  }, {
    "height" : 300,
    "url" : "https://i.scdn.co/image/31327f9fe6b6e0bd6e431a4add681397e95c6329",
    "width" : 300
  }, {
    "height" : 64,
    "url" : "https://i.scdn.co/image/15fed5371098fbf631193332164fba1d0e08c878",
    "width" : 64
  } ],