Error Promise IONIC 2


#1

how to return the "text of error in promise;

if(data.rows.length > 0){
this.storage.executeSql("UPDATE configDB SET loja = ?, servidor = ?, token = ?, itens = ?, servidores = ?", [config.loja, config.servidor, config.token, config.itens, config.servidores])
.then(
(data) => {
this.presentToast("Configuração atualizada com sucesso.");
},
(error) => {
this.presentToast(error);
});

#2

If you’re asking “how do I return the result of an asynchronous operation out of the function that initiated it?”, the short answer is “you can’t”. The longer answer is that the best you can do is return the Promise itself.


#3

no, i want read it: "error"
here:
(error) => {
this.presentToast(error); error = Object
});


#4

You can use JSON.stringify() to guide you as to what the object looks like, but a safer way would be to look at the public API of whatever function is generating the result.


#5

Thanks man, now i can!!