This is my obj, I just want to loop through this and show the errors:
var obj = {
"error": {
"errors": {
"username": {
"properties": {
"message": "username field is empty.",
"type": "required",
"path": "username"
},
"kind": "required",
"path": "username"
},
"email": {
"properties": {
"message": "email field is empty.",
"type": "required",
"path": "email"
},
"kind": "required",
"path": "email"
},
"password": {
"properties": {
"message": "password field is empty.",
"type": "required",
"path": "password"
},
"kind": "required",
"path": "password"
}
},
"_message": "User validation failed",
"message": "User validation failed: username: username field is empty., email: email field is empty., password: password field is empty."
}
}
I want to show the errors: properties.message but I'm having hard time, this is what I tried so far:
for (var key in obj.error.errors) {
for (var key2 in key.properties){
for (var key3 in key2.message){
console.log(key3)
}
}
}
But the console is blank.