【发布时间】:2019-06-26 12:09:54
【问题描述】:
我有以下代码:
export const createCharacter = (username, name, sex, vocation, achievementPoints, world) => {
return (dispath) => {
firebase.auth().signInWithEmailAndPassword('dev7@gmail.com', '123123')
.then(value => {
firebase.database().ref('/sales/')
.push({
owner: username,
character: [
{
name: name,
sex: sex,
vocation: vocation,
achievementPoints: achievementPoints,
world: world
}
],
price: 21.12
})
.then(() => {
})
})
.catch(error => alert(error))
}
}
...有了它,我得到了以下结果:
当我第一次尝试执行 action 方法时,我发现了这个错误:
错误:Reference.push 失败:第一个参数在属性
sales.character.0.name中包含未定义
但是当我第二次不刷新执行时,推送成功了。
我的问题是,我应该如何推送才能不生成此 UID?
【问题讨论】:
-
请在您调用
createCharacter的位置以及调用它返回的函数的位置添加代码。
标签: javascript firebase react-native firebase-realtime-database ecmascript-6