Bear with me as I'm REALLY new to node.js and javascript in general. So, I installed a JavaScript wrapper which gave me classes which can communicate with an API to fetch me information. (I used the LeagueJS wrapper). However, whenever I get the data from the class and then store it in a variable so I can use it in a different class, as soon as I leave the class the variable becomes undefined. I presume this is because I can't use the variable outside of it's scope, is there a way for it to be used? For context, data is an object and id is a Property trying to get the Property value and storing it in the new123 variable. I then want to use the new123 variable as an argument for .gettingLeagueById but cannot achieve this as the variable is undefined. Here's a snippet from my code:
async run(message, summonID){
var SummName = summonID;
api.Summoner
.gettingByName(SummName, 'euw')
.then(data => {
'use strict';
var new123 = data.id;
})
api.League
.gettingLeagueById(new123)
.then(data => {
'use strict';
console.log(data);
});
}