Empty url's in JSON response


#1

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?


#2

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.


#4

It’s located over here: https://bitbucket.org/bartpeperkamp/dionaudio-app-ionic2

Thanks for any help :slight_smile:


#5

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"

#6

data is a Response object. You need to call its json() method to get at the response body.


#7

I already did :slight_smile: But this question can be closed, i found out LastFM was acting dodgy…