RESTful returns undefined in JS Class

0

I'm making changes to the HTML after taking data from the LastFm API, working with class in JS, making method calls within the class itself, where the date was called before, but this returns undefined:

    class Tidal{
        constructor(ev){
            this.dom = ev;
            this.data = {};
            this.elements = {};

            this.getInfo();
            console.log(this)
        }

        getInfo(){
            var self = this.data;

            var lastfm = new LastFM({
              apiKey    : '929cfb240401e3f7c1c0cd531aa1939e',
              apiSecret : 'ac2ecff79d5881a1a8e810f249f052df'
            });

            lastfm.artist.getInfo({artist: 'Madeon'}, {success: function(data){
                self.artistInfo = data;
            }, error: function(code, message){
              console.log(code, message);
            }});

            console.log(self.artistInfo, 12345) // retorna undefined
        }
   }

But when called after the file is loaded into the devTools method it works correctly.

    
asked by anonymous 26.08.2018 / 14:46

0 answers