Issue
Hello i'm trying to access an array from a function what i'am returning work, it's an array but the result in my function "onChangeClient" always display the same "undefined". why ?
Typescript:
Solution
JavaScript (and hence TypeScript) uses lexical scope, meaning you cannot create an Array
in an inner function and access it from outside. What you can do: Create the array in the outer function (getRessource
) and return it from there.
async getRessource(id) {
var ref = ... elided ...
const returnArray = []; // define it here
await ref.once('value' ... elided ... );
return returnArray;
}
Answered By - David
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.