#TypeError Cannot read properties of undefined (reading 'findOne')

30 messages · Page 1 of 1 (latest)

waxen vigil
#

In gateway adapter i receving this error

cobalt egret
#

Showing your code would probably be helpful, 😉

waxen vigil
# cobalt egret Showing your code would probably be helpful, 😉
export class WebsocketAdapter extends IoAdapter {
  private readonly restService: RestService;
  @InjectModel(User.name) private readonly userModel: Model<UserDocument>;
  logger: Logger = new Logger('Gateway');
  constructor(app: INestApplication) {
    super(app);
    this.restService = app.get(RestService);
  }
  .....
cobalt egret
#

Where's the call you're trying to make? What's the stack trace?

waxen vigil
cobalt egret
#

And where is that? What does it look like?

waxen vigil
cobalt egret
#

...

#

If you want to keep showing small snippets of incomplete choice, great. I have no way to help you further

waxen vigil
#

please ping me on response thankyou

waxen vigil
#

It is my adapter file

cobalt egret
#

I'll take a look when I can. Haven't been at my computer all day and mobile doesn't allow me to view the file

waxen vigil
#

Ok

waxen vigil
#

You need to more information?

cobalt egret
#

What I need is for you to realize that I haven't had time to get back to my computer with the holidays going on and needing to spend time with family.

Those of us who provide support here do it for free and on our own time. What may constitute as high priority for you might not for any of us trying to provide support due to what's going on in our lives.

I'll try to get to it by the end of the day, but it might be tomorrow before I get a chance.

cobalt egret
#

Can you also provide the stack trace of the error so I can know what exactly I'm looking at? I think I see where, but want to be certain

waxen vigil
#

Yes please wait i open project

#

i use webpack for compile my app

#

And i have try to print this.userModel and result undefined

cobalt egret
#

How do you use this adapter class? Do you end up calling new to create it?

cobalt egret
#

Then you need to set all properties for the class. Nest will not do any DI for you

waxen vigil
#

So the parameters are not in the constructor

cobalt egret
#

I'll repeat myself: if you use new you have to manage all the dependencies yourself

#

So, you'll need to instantiate the class, then assign adapter.userModel = app.get(getModelToken(User.name), { strict: false }) and then pass the adapter to the use WS adapter method