Jump to content
McKay Development

Cannot read property 'webLogOn' of undefined


Recommended Posts

Posted (edited)

Hi, how can I fix this:

Error: 

 this.client.webLogOn();
                        ^
TypeError: Cannot read property 'webLogOn' of undefined

Code: 

        this.community.on('sessionExpired', function() {
            this.client.webLogOn();
	});

This code is inside SteamBot constructor class

Edited by Trajko
Posted

Inside of that callback function, this refers to the SteamCommunity instance and not the outer context's this. Replace that with an arrow function and it should work as you expect.

this.community.on('sessionExpired', () => {
    this.client.webLogOn();
});

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...