I'm facing an issue with the Chrome API functions being asynchronous, making it difficult for me to get their return value. Here's a snippet of code that demonstrates my problem. I'm working with AngularJS.
$scope.storageGet = function(param) {
var returnData;
chrome.storage.local.get(param.storageName, function(data) {
returnData = data;
});
return returnData;
};
When I attempt to call this function like so:
console.log($scope.storageGet({'storageName': 'users'}));
'undefined' is printed in the console. What I actually want to see is the object of users stored in the Chrome storage. I'm certain that there is data in the Chrome storage.