我正在尝试导入Visual Studio代码,但它给出了此错误import { DataSnapshot } from 'firebase-functions/lib/providers/database';
DataSnapshot' is declared but its value is never read.ts(6133)
这是我index.ts的完整代码,datasnapshot下和错误对象中有红线
exports.sendNotificationOnAssignmentCreated = functions.database.ref('/VoltaCoin/Notifications/{user_id}').onCreate((data, context) =>{
const id = context.params.id;
const eventId = context.eventId;
const user_id = context.params.user_id;
console.log('here is fid 22 ', user_id);
const payload = {
notification:{
title : "You are now assigned",
body : "New Assignment",
icon : "default",
sound : "default"
}
};
var db = admin.database();
var ref = db.ref("/IWFM/Assignments/Olnaj/AFSM/"+user_id+'/assignTo');
ref.on("value", function(snapshot) {
var assignTo = snapshot.val();
var refstaf = db.ref("/IWFM/Stafs/Olnaj/1234/"+assignTo+'/FID');
refstaf.on("value", function(snapshot1){
var FID = snapshot1.val();
console.log('here is ' + FID);
return admin.messaging().sendToDevice(FID, payload).then(response=>{
// console.log('this was the notification feature');
});
}, function(errorObject)
{
console.log("The read failed: " + errorObject.code);
});
}, function (errorObject) {
console.log("The read failed: " + errorObject.code);
});
请有人帮助我修复
答案 0 :(得分:0)
如果不使用它所引用的符号,只需删除整个导入行即可。