#Type 'Number' has no call signatures.

6 messages · Page 1 of 1 (latest)

tiny ravine
#
src/app.controller.ts:19:23 - error TS2349: This expression is not callable.
  Type 'Number' has no call signatures.

19       return response.status(200).json({ message: 'Login successful' });
                         ~~~~~~
src/app.controller.ts:23:23 - error TS2349: This expression is not callable.
  Type 'Number' has no call signatures.

23       return response.status(500).json({ message: errorMessage });
import { Controller, Post, Req, Res} from '@nestjs/common';
import { ClientProxy, Payload } from '@nestjs/microservices';

import { AppService } from './app.service';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  // @Get()
  // getHello(): string {
  //   return this.appService.getHello();
  // }

  @Post('/api/v1/gateway/auth/login')
  async login(@Payload() data: any, @Res() response: Response, @Req() request: Request) {
    try {
      //const resp = await lastValueFrom(this.AuthenticationClient.send('dashboardLogin', data));
      return response.status(200).json({ message: 'Login successful' });
    } catch (error) {
      console.error(`Error occurred - ${error.stack}`);
      const errorMessage = "Failed to complete this action. Please contact Support to help resolve this issue!";
      return response.status(500).json({ message: errorMessage });
    }
  }
}
#

🤔 Not sure what im doing wrong here

cyan scarab
#

What are the Request and Response types here?

tiny ravine
#

I modified the code to include where they were imported from (@nestjs/common)

#

Nvm I figured it out lol, forgot to do import { Request, Response } from 'express';

cyan scarab
#

That would do it