Jump to content
McKay Development
Sign in to follow this  
lll

request has been deprecated

Recommended Posts

 

and another question, why the cookie jar is not used, which is passed in request.defaults

export default class Bot {
    jar = request.jar();

    request = request.defaults({
        jar: this.jar,
        headers: {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'
        }
    });

    constructor(details, db) {
        this.community = new SteamCommunity({
            request: this.request
        });
    }
}

 

after login and several requests, I can’t get Steam cookies in jar

Share this post


Link to post
Share on other sites
16 hours ago, Dr. McKay said:

Probably because it needs to be this.jar = request.jar()

no, this class field is not initialized through the constructor, so this is not needed

this code is equivalent of

export default class Bot {
    constructor(details, db) {
        this.jar = request.jar();
        this.request = request.defaults({
            jar: this.jar,
            headers: {
                'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'
            }
        });
        this.community = new SteamCommunity({
            request: this.request
        });
    }
}

 

Share this post


Link to post
Share on other sites

Oh, I see what you're doing. Didn't look at the code super closely.

node-steamcommunity doesn't currently support supplying your own cookie jar. I can't officially support this, but if you want to use node-steamcommunity's cookie jar for other purposes, you can do something like this:

this.community = new SteamCommunity();
this.jar = this.community._jar;

This is liable to break in a future release, but it will work.

Also, if you want to supply your own user-agent, you need to supply it to the options object as userAgent. Specifying it as a default header in a passed-in request instance won't work.

Share this post


Link to post
Share on other sites

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...
Sign in to follow this  

×
×
  • Create New...