I am trying to pull the boolean value of a checkbox in my popup.html
file in my chrome extension. I have this:
var highlightedCheckBoxVal = $("#highlightedCheckbox").prop("checked");
function getAsync(valueToGet) {
return new Promise((resolve) => {
chrome.storage.sync.get(valueToGet, (value) => {
resolve(value);
console.log("resolved");
})
})
}
//returns object - I want it to return true or false
$(document).keyup(async function (e) {
if (e.keyCode == 120) {
getAsync("highlightedCheckBoxVal").then(val => {
console.log(val);
});
}
});
The console returns an object, and I want it to return a boolean value. I think this is because getAsync
is returning a promise, but how can I make that promise a boolean value?
I have also tried logging val.valueOf()
.