I'm doing a code that makes 3 sequential validations, and I'm using promises, however I understand that there is a structure of promises sequential, but I do not understand how to use it in this case.
valida.user(data).then((rows)=>{
validaciones.user=rows;
})
valida.mail(data).then((rows)=>{
validaciones.mail=rows;
})
valida.ced(data).then((rows)=>{
validaciones.ced=rows;
console.log(validaciones);
})
This brings me back ...
{ user: false, mail: false, ced: false }
... After having validated that there are no records in the database with that same "user", "mail" or "ced"
But I want to implement it this way =
valida.user(data).then((rows)=>{
validaciones.user=rows;
}).then(valida.mail(data)).then((rows)=>{
validaciones.mail=rows;
}).then(valida.ced(data)).then((rows)=>{
validaciones.ced=rows;
console.log("Resultado :"+validaciones);
});
Resultado :[object Object]
My question is what is the correct structure to use the nested .then