Skip to content

Instantly share code, notes, and snippets.

@marifuli
Last active April 2, 2022 16:31
Show Gist options
  • Save marifuli/5b478d3aad5ea68f6d2f40887c4f1157 to your computer and use it in GitHub Desktop.
Save marifuli/5b478d3aad5ea68f6d2f40887c4f1157 to your computer and use it in GitHub Desktop.
JSON object loop of Laravel error response
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