0

I am trying to integrate Firebase into Botkit using botkit-storage-firebase, but I am getting this warning on initialization:

FIREBASE WARNING: Exception was thrown by user callback. TypeError: cb is not a function
    at success (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/botkit-storage-firebase/src/index.js:50:13)
    at c (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:240:58)
    at /Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:201:710
    at ec (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:52:165)
    at ac (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:31:216)
    at $b (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:30:1198)
    at Ri (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:224:313)
    at X.h.Gb (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:238:140)
    at X.h.Og (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:240:249)
    at Object.get (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/botkit-storage-firebase/src/index.js:47:31) 
/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:52
(d="0"+d),c+=d;return c.toLowerCase()}var zd=/^-?\d{1,10}$/;function td(a){return zd.test(a)&&(a=Number(a),-2147483648<=a&&2147483647>=a)?a:null}function ec(a){try{a()}catch(b){setTimeout(function(){R("Exception was thrown by user callback.",b.stack||"");throw b;},Math.floor(0))}}function S(a,b){if(t(a)){var c=Array.prototype.slice.call(arguments,1).slice();ec(function(){a.apply(null,c)})}};function Ad(a){var b={},c={},d={},e="";try{var f=a.split("."),b=Pb(id(f[0])||""),c=Pb(id(f[1])||""),e=f[2],d=c.d||{};delete c.d}catch(g){}return{ph:b,Dc:c,data:d,bh:e}}function Bd(a){a=Ad(a).Dc;return"object"===typeof a&&a.hasOwnProperty("iat")?z(a,"iat"):null}function Cd(a){a=Ad(a);var b=a.Dc;return!!a.bh&&!!b&&"object"===typeof b&&b.hasOwnProperty("iat")};function Dd(a){this.Y=a;this.g=a.n.g}function Ed(a,b,c,d){var e=[],f=[];Na(b,function(b){"child_changed"===b.type&&a.g.Ad(b.Le,b.Ma)&&f.push(new H("child_moved",b.Ma,b.Ya))})

TypeError: cb is not a function
    at success (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/botkit-storage-firebase/src/index.js:50:13)
    at c (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:240:58)
    at /Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:201:710
    at ec (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:52:165)
    at ac (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:31:216)
    at $b (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:30:1198)
    at Ri (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:224:313)
    at X.h.Gb (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:238:140)
    at X.h.Og (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/firebase/lib/firebase-node.js:240:249)
    at Object.get (/Users/ankitshekhawat/Downloads/botkit-master 2/node_modules/botkit-storage-firebase/src/index.js:47:31)

I am initialising it like this.

var Botkit = require('botkit'),
  firebaseStorage = require('botkit-storage-firebase')({firebase_uri: 'https://xxx.firebaseio.com/'}),
      controller = Botkit.slackbot({
          debug: true,
          storage: firebaseStorage
      });

// then you can use the Botkit storage api, make sure you have an id property
var beans = {id: 'cool', beans: ['pinto', 'garbanzo']};
controller.storage.teams.save(beans);
beans = controller.storage.teams.get('cool');
console.log(beans);

However I can see the database entry posted on firebase console succesfully. Problem occurs only on

beans = controller.storage.teams.get('cool');

Any idea how to get around this?

4

1 回答 1

0

botkit-firebase-storage看起来真的过时了(最后一次更新是一年多前,没有更新到 firebase 3.0)。

此外(遗憾的是),这个模块(或我们的产品)的命名令人困惑——它不使用Firebase StorageFirebase Realtime Database数据存储”。

问题来自这里,实际上,cb它似乎不是一个函数,因为它从未填充(.get(ref)返回function(id, cb),从哪里cb初始化?)。

于 2017-01-19T15:59:09.010 回答