last.fm API issues

I am using last.fm JavaScript API (https://github.com/fxb/javascript-last.fm-api) for fetching similar tracks (track.getSimilar).

last.fm API track.getSimilar response

success: function(data) {
  for (var i = 0; i < data.similartracks.track.length; i++) {
    alert("Track Name "+data.similartracks.track[i].name);
  }
}

How do I access small image URL?

I have tried data.similartracks.track.image[0] but it returns me [object Object]

Upvotes: 0

Views: 262

Answers (2)

Thanks for the answer. This worked for me data.toptracks.track[i].image[3]["#text"] // In this case we are getting the 3rd Image URL.

Upvotes: 0

Aylan
Aylan

Reputation: 26

I don't have enough rep to just comment apparently, but my only advice is: in your browser console open your object so you can more specifically access the field containing the url string.

Upvotes: 1

Related Questions