Last active
April 2, 2022 16:31
-
-
Save marifuli/5b478d3aad5ea68f6d2f40887c4f1157 to your computer and use it in GitHub Desktop.
JSON object loop of Laravel error response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(data && data.response && data.response.data && data.response.data.errors) | |
{ | |
for (const error in data.response.data.errors) | |
{ | |
data.response.data.errors[error].forEach(err2 => { | |
createToast(err2, {type: 'danger'}) | |
}) | |
} | |
}else | |
if(data && data.response && data.response.data && data.response.data.message) | |
{ | |
createToast(data.response.data.message, {type: 'danger'}) | |
}else | |
{ | |
// console.log(data) | |
createToast('409 - HTTP conflict. Try again!', {type: 'danger'}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment