我刚从我的函数返回数据,并确认使用console.log,该对象实际上有数据,所以我必须缺少明显的东西,但我只是不知道。
// Variables that do not recive values
var reqSummoner = req.body.summonerName.toLowerCase();
var summonerId;
var summonerLevel;
var profileIcon;
var summonerName;
var games;
lolapi.Summoner.getByName(reqSummoner, function (err, summoner) {
if(!err) {
// attempting to save variables to be accessible outside function
summonerId = summoner[reqSummoner].id;
summonerLevel = summoner[reqSummoner].summonerLevel;
profileIcon = summoner[reqSummoner].profileIconId;
summonerName = summoner[reqSummoner].name;
}
});