I have the following function:
/*global chrome*/
export function retrieveJSON() {
var returnVal;
chrome.storage.sync.get(['deadlinelist'], res => {
let result = res.deadlinelist;
console.log(result, "<- result var");
returnVal = result;
});
console.log(returnVal, "<- returnVal var");
return returnVal;
}
It uses the chrome.storage api and when I try to run it in my chrome extension, the first console.log outputs my expected json object, but when I try to mutate the value returnVal
, it leaves it unchanged, hence the second console.log outputs undefined. I thought variables outside of functions could be mutated, whats the problem?
help needed thanks