I'm using Node, Babel, Express and I have this code
import express from 'express';
import httpinvoke from 'httpinvoke';
export class lolApi{
constructor(summoner, region) {
this.summoner = summoner;
this.region = region;
this.methods = {
"currentGame": `/observer-mode/rest/consumer/getSpectatorGameInfo/${this.region}/`,
"matchList": `/api/lol/${this.region}/v2.2/matchlist/by-summoner/`,
"summonerName": `/api/lol/${this.region}/v1.4/summoner/by-name/`
};
this.domain = `https://${this.region}.api.pvp.net`;
this.apiKey = "xxxxxxxxxx";
}
getSummonerId() {
let url = `${this.domain}${this.methods.summonerName}${this.summoner}?api_key=${this.apiKey}`;
httpinvoke(url, 'GET').then((res) => {
this.data = JSON.parse(res.body);
return this.data;
}, (err) => {
console.log(err);
});
}
}
export default lolApi;
But, when initialize the class whit
let lolapi = new lolApi(summoner, region);
let lolData = lolapi.getSummonerId();
console.log(lolData);
The getSummonerId
method returns undefined, any idea?