How to solve nestjs fastify error TypeError: response.status(...).json is not a function

1.8k Views Asked by At

TypeError: response.status(...).json is not a function at HttpExceptionFilter.catch (/home/muhammedali/Documents/100haryt_v2/src/common/http/http-exception.filter.ts:23:29) at ExceptionsHandler.invokeCustomFilters (/home/muhammedali/Documents/100haryt_v2/node_modules/@nestjs/core/exceptions/exceptions-handler.js:33:26) at ExceptionsHandler.next (/home/muhammedali/Documents/100haryt_v2/node_modules/@nestjs/core/exceptions/exceptions-handler.js:13:18)

1

There are 1 best solutions below

0
sundhar winston On
  response
      .status(status)
      .json({
        statusCode: status,
        timestamp: new Date().toISOString(),
        path: request.url,
      });

instead of using the above code. try to change like as below

  response
      .status(status)
      .send({
        statusCode: status,
        timestamp: new Date().toISOString(),
        path: request.url,
      });