[Solved] Access array from other function [closed]


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;
}

solved Access array from other function [closed]