【发布时间】:2019-05-17 18:52:54
【问题描述】:
我在我的 Restful Node 应用程序中使用 @Decorators。
@Get('/:id')
getUser(@Response() res: any, @Params('id') id: string) {
this.getOneById(res, id)
}
// In Base Controller
async getOneById(@Response() res: any, id: number) {
const item = await this.getOne({ id })
if (item) {
res.send({
success: true,
data: item
})
} else {
this.errorHandler(res, 'No Data with provided id')
}
}
我在基本控制器中定义了getOneById 函数,路径是来自Params 装饰器的id。
但是当我尝试通过console.log(id); 登录时,id 是错误的
有人可以帮忙吗?
【问题讨论】:
标签: javascript node.js typescript decorator