Javascript @使decorator在node.js中无法正常工作

Javascript @使decorator在node.js中无法正常工作,javascript,node.js,typescript,decorator,Javascript,Node.js,Typescript,Decorator,我在Restful节点应用程序中使用@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 })

我在Restful节点应用程序中使用@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 decorator中定义了它的
id
路径。 但是当我试图通过
console.log(id)登录时,
id
是错误的
有人可以帮忙吗?

你应该在装饰功能中添加
async

对我来说很好用。