koa2 router内调外部服务接口503 但postman调外部服务接口正常
node吧
全部回复
仅看楼主
level 1
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
level 1
愿意花点小钱买个知识,求大神教育教育 [泪]急!急 !急!
2020年03月27日 10点03分 2
level 1
我知道问题出在哪里,你对promise的了解太少,
2020年03月29日 04点03分 3
1