0

I have a problem in Nest.js: think about it you have 3 module in nest that name is (a1,b1,c1) (c1) is a class and have a constructor(name,age,lastName) this code is:

@Injectable()
export class Cservice {
  private name: string;
  private lastName: string;
  private age: number;

  constructor(name: string, lastName: string, age: number) {
    this.name = name;
    this.lastName = lastName;
    this.age = age;
  }

  async information() {
    return this.age + this.lastName + this.name;
  }
}

and you need to use this class to (a1) and (b1) << withOut use inheritance >> that means (a1) & (b1) wiht different value and donont use new Cservice(...) and all use with provide in nestjs

I mock the value in both Module (a1) & (b1) with {useClass,useValue} but nest.js error say you should define in app.module and when log in c1.service logs all value Moc in app.module,b1.module ,a1.module

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jun 02 '23 at 23:37
  • we have 3 service And One service has constructor that get name and how to use this service to another service with different value and without use new for call class in Nestjs – Afshin Rahmati Jun 03 '23 at 07:05

0 Answers0