FieldValue.arrayUnion() called with invalid data. Nested arrays are not supported
Will Ceolin
Posted on August 26, 2020
When trying to update an array in Cloud Firestore you might run into this error: FieldValue.arrayUnion() called with invalid data. Nested arrays are not supported
.
However, that error might be a bit misleading. The following code will crash:
firebase.firestore.FieldValue.arrayUnion(['javascript', 'typescript']);
You don't have a nested array per se but your code will fail because Firestore requires you to pass those items individually. All you have to do is using the spread operator instead:
firebase.firestore.FieldValue.arrayUnion(...['javascript', 'typescript']);
💖 💪 🙅 🚩
Will Ceolin
Posted on August 26, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
firebase FieldValue.arrayUnion() called with invalid data. Nested arrays are not supported
August 26, 2020