0

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?

1
  • 1
    The message you see in the console is just a string with some brackets in it. Commented Nov 30, 2020 at 19:53

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.