Well I'm facing the following problem, I'm contributing in a mozilla extension but most of the browser apis use promises to do things, but the problem is that I do not master much. Well I'd really like to know how to return the value of a promise 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");
}
});