0

I get only [] in console. The function is asynchronous, and the console.log runs before function(content). I understand that, but, I can't resolve it.

async function fja() {
    var mydata = [];    

    await Neutralino.storage.getData('notes', function(content) {
        var mydata = content;
    })

    console.log(mydata);
};
Daniel_Knights
  • 7,940
  • 4
  • 21
  • 49
Ante Olić
  • 35
  • 5
  • Does this answer your question? [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – Adam Azad Dec 05 '20 at 14:50

1 Answers1

2

You can declare the variable outside the function:

let data;

Then, inside the function:

data = content;
Daniel_Knights
  • 7,940
  • 4
  • 21
  • 49