R
R
ramazan2016-04-11 13:58:57
JavaScript
ramazan, 2016-04-11 13:58:57

How to get the value of a variable from storage?

There is a function:

function getTokenFromStorage() {
    var key = 'key-aaa';
    var value = 'value-bbb';

    chrome.storage.local.set({'key-aaa': value});

    chrome.storage.local.get(key,function(result){
      alert(result[key]);
    });
}

How can I make this function return the value stored in result[key]?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Bogachev, 2016-04-11
@sfi0zy

Perhaps I did not quite understand the question, do you mean this?

function getTokenFromStorage() {
    ...
    var resultValue;
    chrome.storage.local.get(key,function(result){
        resultValue = result[key];
    });
    return resultValue;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question