2
Well I’m facing the following problem, I’m contributing to a Mozilla extension, but most browser Apis use Preses to do things, only the problem is that I don’t know much. So I would really like to know how to return the value of a precedent to a variable.
a = function() {
var promise = new Promise(function(resolve, reject) {
resolve(browser.storage.local.get().then(function(v) {
ClockFormat=v.formClock;//aqui estou pegando um item do objeto da api
}));
});
return promise;
};
a().then(function(result) {
if(ClockFormat=="12"){
console.log("12 horas");
}else{
console.log("24 horas");
}
});
Obs: a detail that I realized is that the way the code is the Promise can not handle functions that use Return, otherwise it would have ended already.
Have you tried
browser.storage.local.get().then( v => {
 resolve(ClockFormat=v.formClock);
});
?– Valdeir Psr