I am getting the following object from API call:
{
"email": ["The email has already been taken."],
"profile_image": [ "profile image is requried." ]
}
I used the following code to iterate over this object (using for...of):
let message = "";
for (const [error_name, error_value, i] of Object.entries(
error.response.data.errors
)) {
message += `${i}: ${error_value[0]}\n`;
}
But I am getting undefined
instead of getting the value of i
. I want to get the iteration number.
Any suggestions?