2
我为node.js使用sendgrid库。目前有一个回调,它被炒了两次。Node.js回调调用两次
@invite = (email, agencyId, callback) ->
(app.get 'agencies').findOne {_id: agencyId}, {name:1}, (error, agency) ->
sendgrid.send {
to: email,
from: '[email protected]',
subject: "You have been invited to #{agency.name}",
html: "<html><body>Have fun</a></body></html>"
}, (success, message) ->
console.log arguments
if success
console.log callback
callback()
else
console.log message
这是我从控制台
{ '0': true, '1': undefined }
[Function]
{ '0': false, '1': 'Invalid JSON response from server' }
Invalid JSON response from server
的事情是搞定了,我从1路调用函数和它的作品完美的罚款。如果我从另一个单独的路由调用它,它会触发回调,但它表示回调变量(函数)未定义。
任何线索?
我有几次......它只被调用一次。 – elbuo