后端搭建起来

This commit is contained in:
aixianling
2022-12-30 16:34:57 +08:00
parent b8ac23dcfd
commit d1f2a42f1c
3 changed files with 8 additions and 4 deletions

View File

@@ -10,7 +10,7 @@ module.exports = () => async function errorHandler(ctx, next) {
? 'Internal Server Error'
: err.message;
// 从 error 对象上读出各个属性,设置到响应中
ctx.body = {error};
ctx.body = {code: 1, error};
if (status === 422) {
ctx.body.detail = err.errors;
}