【发布时间】:2017-09-23 00:04:41
【问题描述】:
尝试使用 Bluebird promisifyAll 来包装 oauth 的方法,如下所示:
const Promise = require('bluebird')
const OAuth = Promise.promisifyAll(require('oauth'), {
multiArgs: true
}).OAuth
并像这样使用:
const result = await this.oauth.getOAuthAccessTokenAsync(
// token,
// tokenSecret,
// verifier
)
(注释掉参数以强制出错)
但是,我的应用程序没有掉入周围的 try/catch 的 catch 块,而是崩溃(来自 oauth 库):
if( error ) callback(error);
^
TypeError: callback is not a function
我还需要做些什么来正确处理错误吗?
【问题讨论】:
标签: node.js oauth promise bluebird