I've been trying to use chrome.storage.sync.get for the options part of my program but I've hit a snag.
document.addEventListener('DOMContentLoaded', function() {
document.getElementById("save").addEventListener("click", save_options);
});
function save_options() {
var priceNotif = document.getElementById('pricealert').value;
chrome.storage.sync.set({
priceAlert: priceNotif
}, function() {
// Update status to let user know options were saved.
console.log("price set: " + priceNotif);
setTimeout(function() {
status.textContent = '';
}, 750);
});
}
var test = chrome.storage.sync.get('priceAlert', function(data) {
test = data.priceAlert;
});
console.log("test price get: " + test);
The test variable is returning undefined, and how do I fix that?