【发布时间】:2018-12-06 20:51:45
【问题描述】:
假设我想在 NodeJs 中使用 Promise 时转换一个错误。
因此,例如在下面的代码中使用 request-promise 模块,我试图在为某个 URI 创建 GET 时将错误修改为更简单的错误。
const options = {
'uri': uri,
'headers': { 'Accept-Charset': 'utf-8' }
}
rp.get(options)
.catch(err => {
throw {'statusCode': err.statusCode ? err.statusCode : 503}
})
我是否可以像使用return 时那样省略大括号?
【问题讨论】:
标签: node.js lambda promise arrow-functions