我将 angular 与 firebase 结合使用,并尝试使用以下代码将数据添加到我的 firestore 集合中:但我不断收到错误消息:
ERROR FirebaseError: Function DocumentReference.set() called with invalid data. Unsupported field value: a custom object (found in document web_record_tab_test/Z7zP7Tze1OwZfPkFKJph
我尝试了在另一个 stackoverflow 问题上给出的不同答案,但无法找到解决方案。这是我的代码:
let dataArray=dataAppFormat.map((obj)=> {return Object.assign({}, obj)});
let data={
data: dataArray,//.map((obj)=> {return Object.assign({}, obj)}),
load: "updated",
type:"RichTextBlock"
};
let ref=this.firestore.collection('web_record_tab_test');
ref.doc().set(data).then(function() {
console.log("Document successfully written!");
这里的 dataAppFormat 是一个数组,我将它创建到一个 JS 对象数组中,并创建了一个 Js 对象并尝试将其添加到文档中。关于我可能出错的地方有什么建议吗?