将阵列添加到Firebase

时间:2019-01-27 00:17:38

标签: reactjs firebase google-cloud-firestore

我有一个包含对象的pages数组。每个对象都包含一个称为块的项目数组。尝试添加错误消息时,解决此问题的最佳方法是什么?

     let projectId = Math.floor(Math.random() * 10000);
     let docTitle = this.projectTitle.title;

     this.pages.forEach((page) => {
       let pageT = page.pageTitle;
       let pageD = page.pageDesc;
       let id = page.id;
       let blocks = page.blocks;
       db.collection(docTitle + projectId).doc(pageT).set({
           page: {pageTitle:pageT, pageDesc: pageD, blocks:blocks, id:id }
         })
         .then(function() {
           console.log("Document successfully written!");
         })
         .catch(function(error) {
           console.error("Error writing document: ", error);
         });
     })

这是错误: enter image description here

0 个答案:

没有答案