我有这个代码
this.db.collection("users").doc(this.name_user).update({
data
})
.then(function() {})
.catch(function(error) {
console.log("Error! " + error);
});
执行代码后,出现以下错误
core.js:1449 ERROR Error: Function DocumentReference.update() called with invalid data. Unsupported field value: undefined
at new FirestoreError (error.js:149)
at ParseContext.createError (user_data_converter.js:162)
at UserDataConverter.parseScalarValue (user_data_converter.js:439)
at UserDataConverter.parseData (user_data_converter.js:339)
at user_data_converter.js:362
at Object.forEach [as c] (obj.js:49)
at UserDataConverter.parseObject (user_data_converter.js:361)
at UserDataConverter.parseData (user_data_converter.js:331)
at UserDataConverter.parseArray (user_data_converter.js:347)
at UserDataConverter.parseData (user_data_converter.js:327)
知道为什么会发生此错误吗?或者我的代码有问题吗?
我收到一个json并使用FOR循环处理数据,这是代码:
for (var i = 0; i < data.length; i++) {
if(data[i].id_expediente === this.id_exp ){
console.log("update status");
datos.splice(i, 1, {id_exp: data[i].id_exp,
demandado: data[i].name,
direccion: data[i].address,
status: "start"
});
}
}
(在此之后)用于打印控制台数据
[
{
"id_exp": "8989",
"name": "user_name",
"address: "Mexico, Mexico",
"status": "start"
}
,
{
"id_exp": "8990",
"name": "user_name2",
"address": "Mexico, Mexico",
"status": ""
},
{
"id_exp": "8995",
"name": "user_name3",
"address": "Mexico, Mexico",
"status": ""
}
]