Reputation: 451
I am using Firebase Auth to create users and logging the error so that I can display it to the user. This logging is currently in test and goes as follows:
console.log(error);
console.log(typeof(error))
In my console I get the following:
[Error: [auth/invalid-email] The email address is badly formatted.]
object
Usually when I get an object it is returned in some kind of {} format so I am confused why it is now in seemingly-array-like format? Could someone shed on light on how this works?
Upvotes: 0
Views: 553
Reputation: 181
In Javascript, arrays are actually objects with some additional functionality. So typeof([])
will return object
.
It looks like the api is returning an array of Error objects. If you wanted to display those errors to the user, you could loop through the returned array and print/concatenate each Error's message
property.
Upvotes: 1