Debes usar async y await en este caso.
function who() {
return new Promise(resolve => {
setTimeout(() => {
resolve('Prueba');
}, 200);
});
}
function what() {
return new Promise(resolve => {
setTimeout(() => {
resolve('de methodos');
}, 300);
});
}
function where() {
return new Promise(resolve => {
setTimeout(() => {
resolve('async await');
}, 500);
});
}
/*Sin async await*/
function test() {
console.log("Entro a la funcion test");
who()
.then((response) => {
console.log(`response who: ${response}`);
console.log("Llamando a what");
what()
.then((response) => {
console.log(`response what: ${response}`);
console.log("Llamando a where");
where()
.then((response) => {
console.log(`response where: ${response}`);
console.log("termino");
});
});
})
console.log("ultima linea de la funcion test");
}
/* Con async/await */
async function msg() {
const a = await who();
const b = await what();
const c = await where();
console.log(`${return a[a, b, c]
}
async $function testing() {
b }const ${retorno c= }`await msg();
const transformado = retorno.map(v => v.toUpperCase())
console.log(transformado)
}
await testing()