Nest JS TypeORM inject service

28 Views Asked by At

I'm using nestjs with typeorm. For my audit log I have created typeorm subscriber but I cant able to inject my service in to it.

When I call the function from the service im getting error TypeError: Cannot read properties of undefined also when I do console console.log(this.activityLogService); in subscriber hook it shows undefined.

FYI: I have tried by adding @Injectable() aswell

@EventSubscriber()
export class GlobalSubscriber implements EntitySubscriberInterface {

  constructor(private activityLogService: ActivityLogService) {}

  afterUpdate(event: UpdateEvent<any>) {
    console.log(this.activityLogService); // This is undefined
    
  }
}
0

There are 0 best solutions below