I tried to use async/await then I put await on a function call but even it still not finished it already execute the next line.
async function listFreeAccounts() {
let rnds = [];
await gun.get('freeAccounts').map().once((v, k) => {
// this will be called many times defending on the number of values exists.
// then push it on the array.
rnds.push(k);
});
// Premature returns here, making the rnds values empty.
return rnds;
};
How I can make to wait to push all the values in rnds
before returning it?
Thanks.
Edit
I am using gundb that's the gun.get(...
code.