Complete the code to import the necessary NestJS module for interceptors.
import { [1] } from '@nestjs/common';
The NestInterceptor is imported from @nestjs/common to create logging interceptors.
Complete the code to implement the NestJS interceptor interface.
export class LoggingInterceptor implements [1] {
The NestInterceptor interface must be implemented to create an interceptor.
Fix the error in the method signature to correctly intercept the request.
intercept(context: ExecutionContext, [1]: CallHandler): Observable<any> {The second parameter is conventionally named next and is of type CallHandler.
Fill both blanks to log the request method and URL inside the interceptor.
const request = context.switchToHttp().getRequest();
console.log(`Request: ${request.[1] ${request.[2]`);The method and url properties of the request object give the HTTP method and URL.
Fill all three blanks to complete the interceptor's return statement that logs after the response is sent.
return next.handle().pipe(tap(() => { console.log(`Response sent for ${context.switchToHttp().getRequest().[1] ${context.switchToHttp().getRequest().[2]`); console.log(`Execution time: ${Date.now() - [3]ms`); }));
The method and url log the request details, and startTime is used to calculate execution duration.