I have the following code:
const execute = function() {
return new Promise((resolve, reject) => {
setTimeout(() => {
console.info('Iniciou');
resolve('Executando');
console.info('Finalizou');
}, 1000);
})
.then((data) => {
console.info(data);
})
.catch((err) => {
console.error(err);
});
};
execute();
As you can see the execution of this code generates as output:
// Iniciou
// Finalizou
// Executando
I honestly have no idea why this happens, if anyone can clarify this doubt.