首页 > 解决方案 > 返回 POST 请求响应后运行方法

问题描述

我对 JS 很陌生,我正在使用 NestJS 和 mongo 来开发后端 api。我有一个基本的 CRUD 操作。我希望能够创建文档,将其返回给用户并运行另一种方法而不影响用户。

  @Post()
  async create(@Body() body: Dto, @Headers('id') id: string) {   
    body.id = id;    
    const item = await this.service.create(body);
    return item;

  // Now, I want to call another method async to trace history changes 
  }

标签: node.jsasynchronousasync-awaitcontrollernestjs

解决方案


有两个选项可以解决此选项


推荐阅读