2
I have the following function below:
public requisicaoXPTA() {
this.database.executeSql("SELECT * FROM tbl_xpta",
[]).then((data) => {
// o resultado retorna aqu na variável data
}, (error) => {
console.log(error);
});
}
When I use this function I do this way:
this.requisicaoXPTA();
this.atualizar();
Most of the time, the function atualizar()
is executed before the requisicaoXPTA()
. I’d like to perform the function atualizar()
after having made the request in the table. What better way to do this synchronously?
Ever tried to use async and await?
– DiegoAugusto
A kick, how about adding the
this.atualizar
within the.then
?– Guilherme Nascimento
@Guillhermenascimento if he wears
this.atualizar
within the.then
works, but I would like to add therequisicaoXPTA
in another file (class), other than where thethis.atualizar
if found. So for this reason I wanted to first receive the result of the function and then proceed to update.– viana
@Diegoaugusto did not try no. I will take a look to see how it works there. Thanks to the tip.
– viana
@acklay I will put an example in the answers.
– DiegoAugusto