在进入我的控制器之前,我需要在我的拦截器上获取请求正文:
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) 如何在HttpService使用NestJs时使用Async / Await?以下代码不起作用:
async create(data) {
return await this.httpService.post(url, data);
}
Run Code Online (Sandbox Code Playgroud)