我試圖包裝Twilio節點客戶端,以便我可以從我的Meteor應用程序訪問和使用它。我正在使用npm-container
並將twilio軟件包添加到我的packages.json
文件中。然後我創建一個Meteor方法來調用並試圖包裝NPM包調用以發送SMS消息。使用wrapAsync在一個Meteor應用程序中包裹Twilio節點客戶端失敗
sendSMS: function() {
var twilio = Meteor.npmRequire('twilio');
var client = new twilio(Meteor.settings.TWILIO.SID, Meteor.settings.TWILIO.TOKEN);
var options = {
to: Meteor.settings.TWILIO.TO,
from: Meteor.settings.TWILIO.FROM,
body: 'word to your mother.'
};
var sms = Meteor.wrapAsync(client.sendMessage, client);
return sms(options);
}
但是,當我打電話Meteor.call('sendSMS');
從我的流星客戶端,我得到一個內部服務器錯誤...
I20150603-12:05:29.254(-4)? Exception while invoking method 'sendSMS' [object Object]
I20150603-12:05:29.254(-4)? at Object.Future.wait (/Users/jeremyhodges/.meteor/packages/meteor-tool/.1.1.3.1wysac9++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:398:15)
I20150603-12:05:29.254(-4)? at packages/meteor/helpers.js:119:1
I20150603-12:05:29.254(-4)? at [object Object].Meteor.methods.sendSMS (app/server/index.js:229:12)
I20150603-12:05:29.254(-4)? at [object Object].methodMap.(anonymous function) (packages/meteorhacks:kadira/lib/hijack/wrap_session.js:160:1)
I20150603-12:05:29.254(-4)? at maybeAuditArgumentChecks (packages/ddp/livedata_server.js:1617:1)
I20150603-12:05:29.255(-4)? at packages/ddp/livedata_server.js:648:1
I20150603-12:05:29.255(-4)? at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20150603-12:05:29.255(-4)? at packages/ddp/livedata_server.js:647:1
I20150603-12:05:29.255(-4)? at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20150603-12:05:29.255(-4)? at [object Object]._.extend.protocol_handlers.method (packages/ddp/livedata_server.js:646:1)