I'm trying to get the url to my most recently played song's album image using last.fm's spotify scrobble api. I'm able to get the song name and artist, but the text for the link to the song's album image is returning "object%20Object" or "object Object".
var img = new Image();
img.setAttribute("src", $.get("https://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=plggs&api_key=MY_API_KEY&limit=1&format=json", function (data, status) {
$("#album-art").html(data["recenttracks"]["track"][0]["image"][2]['#text']);
}));
img.setAttribute("class", "album-img");
img.setAttribute("alt", "album");
document.getElementById("album-art-div").appendChild(img);
Here's the json that last.fm is returning:
{"recenttracks":{"track":[{"artist":{"#text":"Jason Mraz","mbid":"82eb8936-7bf6-4577-8320-a2639465206d"},"name":"I Won't Give Up","streamable":"0","mbid":"7a49cb65-1f22-4334-b139-6500c2e79ee5","album":{"#text":"I Won't Give Up","mbid":"6e680b82-fa31-4342-87b6-1c306d4fb90c"},"url":"https://www.last.fm/music/Jason+Mraz/_/I+Won%27t+Give+Up","image":[{"#text":"https://lastfm-img2.akamaized.net/i/u/34s/6288819e941d491584fa6fa66b8e903f.png","size":"small"},{"#text":"https://lastfm-img2.akamaized.net/i/u/64s/6288819e941d491584fa6fa66b8e903f.png","size":"medium"},{"#text":"https://lastfm-img2.akamaized.net/i/u/174s/6288819e941d491584fa6fa66b8e903f.png","size":"large"},{"#text":"https://lastfm-img2.akamaized.net/i/u/300x300/6288819e941d491584fa6fa66b8e903f.png","size":"extralarge"}],"date":{"uts":"1517936832","#text":"06 Feb 2018, 17:07"}}],"@attr":{"user":"PlGGS","page":"1","perPage":"1","totalPages":"103","total":"103"}}}
Does anyone know how to specifically get the album's 'extralarge' image url?