I have been working on this app for like 3 months which is near completion. But since yesterday I have been unable to solve this problem. I want to use activityTypeService in activityLogService and I have been getting this wired error. I have already exported activityTypeservice in its module. see below
below is ActivityTypeModule, I export ActivityTypeService so it can available in ActivityLogService
@Module({
imports: [MongooseModule.forFeature([{ name: 'ActivityType', schema: ActivityTypeSchema },])],
providers: [ActivityTypeService,],
controllers: [ActivityTypeController],
exports: [ActivityTypeService,]
})
export class ActivityTypeModule { }
The code below is activityLog module and ActivityTypeModule is imported
@Module({
imports: [MongooseModule.forFeature([{ name: 'ActivityLog', schema: ActivityLogSchema }]), ActivityTypeModule],
providers: [ActivityLogService, ActivityTypeModule],
controllers: [ActivityLogController],
exports: [MongooseModule,]
})
export class ActivityLogModule { }
so I use it the activityLogService as shown below
@Injectable()
export class ActivityLogService {
constructor(@InjectModel('ActivityLog') private activitylogModel: Model<ActivityLog>,
private activityTypeService: ActivityTypeService
) { }
async activitylog(activityuser: string, activitytype: string, activitydetails: string, activitydate: Date) {
const activitiesLog = {
activityuser: activityuser,
activitytype: activitytype,
activitydetails: activitydetails,
activitydate: activitydate
}
const activity = new this.activitylogModel(activitiesLog);
console.log(activity);
await activity.save()
}
}
But I am still getting this wired error which I dont understand
Nest can't resolve dependencies of the ActivityTypeService (?). Please make sure that the argument ActivityTypeModel at index [0] is available in the ActivityTypeService context.
Potential solutions:
- If ActivityTypeModel is a provider, is it part of the current ActivityTypeService?
- If ActivityTypeModel is exported from a separate @Module, is that module imported within ActivityTypeService?
@Module({
imports: [ /* the Module containing ActivityTypeModel */ ]
})
ActivityTypeModulefrom theprovidersarray of theActivityLogModule? - Apokralipsa