I’m looking up artist (music) information via last.fm (via a service/provider), all works well, however all the urls for images are empty.
JSON response looks something like this (the urls are normally filled with image urls):
0 Object
-
#text: ‘’
- size: 'small’
1 Object
-
#text: ‘’
- size: ‘large’
I figure this data has to be sanitised in some way, but i’m can’t figure out how to do that in Ionic2. Can anybody help me here?
Not a whole lot of information on how to recreate this.
Could you build a simple demo and put it on to github?
We need some code in order to debug.
To clarify, it is about this service/provider:
lookupArtist(artist) {
return this.http.get('http://ws.audioscrobbler.com/2.0/?method=artist.getInfo&artist=' + encodeURIComponent(artist) + '&api_key=' + token + '&format=json').map((res: Response) => res.json());
}
I use it like this:
this.information.lookupArtist(JSON.stringify(this.currentItem.label)).subscribe(
data => {
if (data.error == 6) {
console.log('not found');
} else {
//var image_url = JSON.parse(data._body);
console.log(data.artist.image);
//this.image = image_url.artist.image[4]['#text'];
}
},
err => console.log('error')
);
The urls are removed from #text:
0:Object
#text:""
size:"small"
1:Object
#text:""
size:"medium"
data
is a Response
object. You need to call its json()
method to get at the response body.
I already did
But this question can be closed, i found out LastFM was acting dodgy…