level 1
bogus备忘录
楼主
router.get('/report', async (ctx, next) => {
console.log(ctx.header);
if (!ctx.query.id) {
ctx.throw(400, '参数失败')
} else {
await next()
}
}, async (ctx, next) => {
getReport(ctx.query.id, ctx.header).then(res => { //report方法中用request调了外部服务接口
ctx.body = {
code: 200,
data: {
...res.data
}
}
}).catch(e => {
ctx.throw(400, '系统异常') //这一行没生效
})
});
不仅如此 service还会 报UnhandledPromiseRejectionWarning
求大神辅助解决该问题
2020年03月27日 10点03分
1
console.log(ctx.header);
if (!ctx.query.id) {
ctx.throw(400, '参数失败')
} else {
await next()
}
}, async (ctx, next) => {
getReport(ctx.query.id, ctx.header).then(res => { //report方法中用request调了外部服务接口
ctx.body = {
code: 200,
data: {
...res.data
}
}
}).catch(e => {
ctx.throw(400, '系统异常') //这一行没生效
})
});
不仅如此 service还会 报UnhandledPromiseRejectionWarning
求大神辅助解决该问题