小编And*_*eri的帖子

NestJs - 如何在拦截器上获取请求正文

在进入我的控制器之前,我需要在我的拦截器上获取请求正文:

import { Injectable, NestInterceptor, ExecutionContext, HttpException, HttpStatus } from '@nestjs/common';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

@Injectable()
export class ExcludeNullInterceptor implements NestInterceptor {
    intercept(context: ExecutionContext, call$: Observable<any>): Observable<any> {
        // How can I get the request body here?
        // Need to be BEFORE the Controller exec
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript node.js nestjs

9
推荐指数
1
解决办法
5107
查看次数

NestJs异步httpService调用

如何在HttpService使用NestJs时使用Async / Await?以下代码不起作用:

async create(data) {
    return await this.httpService.post(url, data);
}
Run Code Online (Sandbox Code Playgroud)

javascript node.js typescript nestjs

2
推荐指数
3
解决办法
3028
查看次数

标签 统计

javascript ×2

nestjs ×2

node.js ×2

typescript ×1