Currently, I'm working on developing a Chrome extension that focuses on conversions. However, I've hit a roadblock when it comes to retrieving data from storage. Below is the code snippet I'm currently using:
var conversionFactor = 1;
chrome.storage.sync.get("conversion", function(fetched) {
var tempCon = fetched.conversion;
if(tempCon.includes('toKG')) {
conversionFactor = 0.45;
}
else {
conversionFactor = 2.2;
}
});
alert(conversionFactor);
Despite my efforts, the alert always displays a value of 1. Is it not supposed to update the value before the alert is triggered? Additionally, I'm curious if there's a way to extract a value from chrome.storage and use it outside of the callback function within the chrome.storage.sync.get statement.