209 похожих чатов

Подскажите пожалуйста. Делаю логгер через мидлвару. В сваггере вижу контент тайп

респонса, а в мидлваре через response.getHeader() его нет.

Как можно получить?

4 ответов

11 просмотров

Я не нейронка, но может res.contentType

🦜- Автор вопроса

import { Injectable, NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common'; import { Observable } from 'rxjs'; import { tap } from 'rxjs/operators'; @Injectable() export class LoggerInterceptor implements NestInterceptor { intercept(context: ExecutionContext, next: CallHandler): Observable<any> { return next .handle() .pipe( tap(() => { const http = context.switchToHttp(); const response = http.getResponse(); const contentType = response.getHeader('content-type'); console.log(`Content Type: ${contentType}`); }), ); } }

🦜- Автор вопроса
Vladisλav
import { Injectable, NestInterceptor, ExecutionC...

у меня через logger function interceptor

Похожие вопросы

Карта сайта