【问题标题】:DataSnapshot' is declared but its value is never read.ts(6133)DataSnapshot' 已声明,但其值永远不会被读取。ts(6133)
【发布时间】:2019-08-24 04:12:05
【问题描述】:

我正在尝试在 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);
});

如果有人可以帮我解决一下问题

【问题讨论】:

    标签: typescript firebase firebase-realtime-database google-cloud-firestore firebase-cloud-messaging


    【解决方案1】:

    如果您不使用它引用的符号,只需删除整个导入行。

    【讨论】:

      猜你喜欢
      • 2021-11-08
      • 2022-10-13
      • 1970-01-01
      • 2019-06-23
      • 1970-01-01
      • 2022-06-29
      • 1970-01-01
      • 2022-08-10
      • 2018-09-28
      相关资源
      最近更新 更多