0

I am trying to update a variable item with a string in chrome storage to then use it outside the function. Can anyone tell me what i'm doing wrong?

var item;

chrome.storage.sync.get('myLine', function(data) {
    item = (data.myLine);
});

alert(item);

Sorry if this is obvious I'm just learning, Thank you.

Lachlanf
  • 33
  • 7
  • 2
    Possible duplicate of [How do I return the response from an asynchronous call?](http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – wOxxOm Aug 11 '16 at 07:46
  • Basic questions were asked many times so usually you can find an answer or a working example in less than a minute by googling "chrome.storage.sync.get example" and so on. – wOxxOm Aug 11 '16 at 07:53

0 Answers0