akos-handcustomcode
v0.0.3
Published
hand custom formatting return for akos
Downloads
2
Readme
akos-handCustomCode
hand custom formatting return
introduce
- option.ResponseCode
The custom code you want.
// default { Success: 200, Unauthorized: 401, Invalid: 403, NotFound: 404, InternalError: 500, }
- Provide method
- throwCodeError
- setCodeError
- setBodyResult
- setBodyContent
- for example
async userInfo() {
const ctx = this.ctx;
// a method to get user from mysql
const user = await ctx.service.user.getInfo()
ctx.setBodyContent(200, user)
}
you will get the result
{
code: 200,
result: {
//....userInfo....
}
}