对不起,我的英语是法语。 我有这个错误
firebase.js:1 Uncaught (in promise) Error: Reference.child failed: First argument was an invalid path = "CUG04,CJS98,CJS17,CKJ50". Paths must be non-empty strings and can't contain ".", "#", "$", "[", or "]"
at validatePathString (firebase.js:1)
at t.child (firebase.js:1)
at database.ref.once.then.snapshots (generate-token.js:57)
您能帮我吗?我在一个数组中有很多数据,我想像许多孩子一样在firebase数据库中设置
这是我的代码:
enter code here $.ajax({
type: "GET",
dataType: "json",
url: link json
success: function (data) {
$('#resultat').html("fichier ");
if (data != '') {
myJsonObj = data
}
var taillemyJsonObj = myJsonObj.length;
for (var j = 0; j < filteredAndMappedSubjects.length; j++) {
console.log("ok");
for (var i = 0; i < taillemyJsonObj; i++) {
if (filteredAndMappedSubjects[j] === myJsonObj[i].title.en) {
sequenceid[i] = myJsonObj[i].sequenceId;
}
}
}
console.log(sequenceid);
resetUserInterface(sequenceid);
},
});
});
})
这是我的接收功能,通常将每个序列ID设置到数据库firebase中
function updateSubscriptiononserver(currentToken, sequenceid) {
if (isSubscribed) {
ref.on('value', function (snap) {
sequenceid = snap.val();
console.log("okkk")
})
return database.ref("/tokens").orderBychild("uid").equalTo(currentToken)
.on('child_added', snapshort => snapshort.ref.remove())
console.log("okkk")
}
database.ref('/tokens').once('value')
.then(snapshots => {
let deviceExists = false
snapshots.forEach(childSnapshot => {
if (childSnapshot.val() === currentToken) {
deviceExists = true
return console.log('Device already registered.');
}
})
console.log("oooooooo", sequenceid);
if (!deviceExists) {
return database.ref(`/tokens`).child(sequenceid).set({
token: currentToken,
})
}
})
}