claudiowilson/LeagueJS

Return values 'undefined'

Closed this issue · 4 comments

First of all thank you for creating something useful.

I'm having a problem, when trying to return a value, it defines as undefined, see:

var list = LolApi.getChampions(true, (err, champs) => champs);
console.log(list); //#undefined

The methods are asynchronous, so you need to continue working with the value you get within the the callback.

var list = LolApi.getChampions(true, (err, champs) => {
    console.log(champs);
}

With the rework in progress now all methods will return Promises, which should then be a bit more obvious.

@Colorfulstan Thanks for replying, I'm working with ExpressJS and would like to pass the variable as a template parameter to be displayed in HTML.

Would?

You need to look it up in the express documentation.
You now know where the variable comes from, that's all I got.

Issue can be closed imo.

This really is more like a ExpressJS or template engine issue.

Like @Colorfulstan said you now know where to get the variable you need but how you get this variable into the template engine you're using is not in our scope.

This might help: https://expressjs.com/en/guide/using-template-engines.html

Closing the issue here.