In angular I've tying to loop my given errors and show them in alert but it doesn't work, I've read and tried different solutions such as using lenght or lenght+1 etc. none of them seem to work.
Data
{name: Array(1), email: Array(1), password: Array(1)}
email: ["The email field is required."]
name: ["The name field is required."]
password: ["The password field is required."]
__proto__: Object
Code
error => {
let errors = error.error.errors;
console.log(errors); //return result above
for (var i = 0; i < errors.length; i++) {
this.alertService.presentToast(errors[i]);
}
},
any idea?
errors[i]and check what is the output?The content doesn't matterthe matter is that i canloop and show that contentwhat ever it is.errors.name[0]below your console and above for loop then it will print output.