[Vuejs]-How to store an array of data in an array of objects in firestore using vue.js

0👍

Welcome on Stack!

I am not sure what you are trying to do, however for sure, if you iterate over the array with index you should use < not <= like:

for(i=0; i<this.usernames.length; i++)

Otherwise, in last iteration you are out of index range. This is because index starts with 0, so last index is array length – 1.

2nd thing is that I am not sure if this update inside loop will work as this is asynchronous function (reference). I suggest to create whole field and than update it in one update statement.

I hope it will help!

Leave a comment