This works
chrome.storage.local.get(\'sizePref\', function(items) { // Get size preferences from storage
var sizePref2 = items.sizePref.tops; // Set size to a
If you are not familiar with promises (viz. unlikely) then you can use callbacks too. I personally think promises are a better way to solve your issue.
function getSize(itemSize, callback) {
chrome.storage.local.get('sizePref', function(items) {
// Get size preferences from storage
var sizePref = items.sizePref[itemSize]; //thanks @jfriend00
callback (sizePref); //thanks at @Kevin Friedheim
});
}
var mySize = getSize(tops, function (mySize) {
console.log("This size that u are looking for is " + mySize)
});