【发布时间】:2017-09-04 01:32:04
【问题描述】:
我在向 Firebase 发送空数据时遇到问题,并且收到以下错误消息:
运行时错误 Reference.update 失败:第一个参数在属性中包含未定义
我有:
public save(url: string, params: any) {
return this.af.database.ref('alunos').push().set(params);
}
作为我发送的参数:
this.aluno = {
bairro: '',
celular: '',
cep: '',
cidade: '',
cpf: '',
dataNascimento: '',
email: '',
nome: '',
numero: null,
rg: '',
rua: '',
ativo: true,
genero: null,
telefone: '',
uf: ''
};
我已经知道 Firebase 不接受 undefined 但我使用的是 null,所以这不应该发生吗?有什么办法可以在不改变字符串等数据结构的情况下解决这个问题?
【问题讨论】:
-
您能否分享您尝试发布到 Firebase 的内容,以便我们更好地了解该问题。您可以毫无问题地通过
null。 -
你去吧,我希望你明白。
-
你在和
angularfire2一起工作吗?这是一个有效的命令吗?return this.af.database.ref('alunos').push().set(params);不应该是this.af.list('alunos').push(params);吗? -
@sketchthat 我正在使用 ionic,this.af.database.ref('alunos').push().set(params);是错误的方式,现在我正在使用 this.af.database.ref('alunos').push(params);我应该使用列表('alunos')吗?有什么区别吗?
-
我不确定,我还没有看到
ref的文档。使用list将为您的数据库写入生成唯一键。
标签: typescript firebase firebase-realtime-database