¿Es posible usar waitit sin async en Js
Aguardar es una característica sorprendente en es7.
Sin embargo, cada vez que uso aguardar descubrí que tengo que definir una función asincrónica y llamar a esta función.
Como
async function asy(){
const [resCityGuess,resCityHot,resCityAll]=await Promise.all([
this.http.get('api/v1/cities?type=guess'),
this.http.get('api/v1/cities?type=hot'),
this.http.get('api/v1/cities?type=group')
])
this.cityGuessName=resCityGuess.data.name;
this.cityGuessId=resCityGuess.data.id;
this.cityHot=resCityHot.data;
this.cityAll=resCityAll.data;
}
asy.apply(this);
Lo que quiero es usar waitit sin una función asíncrona como
// the async function definition is deleted
const [resCityGuess,resCityHot,resCityAll]=await Promise.all([
this.http.get('api/v1/cities?type=guess'),
this.http.get('api/v1/cities?type=hot'),
this.http.get('api/v1/cities?type=group')
])
this.cityGuessName=resCityGuess.data.name;
this.cityGuessId=resCityGuess.data.id;
this.cityHot=resCityHot.data;
this.cityAll=resCityAll.data;
// without call fn
Creo que definir la función fn y llamar a esto fn se repite a veces, así que quiero saber si es posible optimizar la situación?
¿Puedo usar await sin async?
Muchas gracias!