这是我的代码:
var pushRef = currentAssignment.child('answers').push().catch(e => console.log('push', e));
pushRef.set({
// downloadURL: downURL,
textAnswer: textAnswer,
date: this.generateDate(),
seen: false,
// firebaseKey: pushRef.getKey(),
workKey: this.props.questionId
})
当我尝试运行它时,出现以下错误:
pushRef.set()
,但是根据this part of the documentation,它对我来说似乎是我以相同的方式进行操作。这是Google的推送指令示例:var postsRef = ref.child("posts");
var newPostRef = postsRef.push();
newPostRef
.set({
author: "gracehop",
title: "Announcing COBOL, a New Programming Language"
});
// we can also chain the two calls together
postsRef
.push()
.set({
author: "alanisawesome",
title: "The Turing Machine"
});
那我想念什么呢?
最佳答案
通过在.catch(e => console.log('push', e))
后面添加push()
,可以将其从Firebase数据库引用更改为其他内容。因此,将其删除将解决此问题。
据我所知,调用push()
(不带参数)永远不会产生错误,它只是生成Firebase引用(唯一键)客户端。