我有一个包含对象的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);
});
})