lll Posted May 17, 2020 Report Posted May 17, 2020 request has been deprecated, so is planned to switch to another requests lib? Quote
lll Posted May 18, 2020 Author Report Posted May 18, 2020 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 Quote
Dr. McKay Posted May 19, 2020 Report Posted May 19, 2020 Probably because it needs to be this.jar = request.jar() Quote
lll Posted May 19, 2020 Author Report Posted May 19, 2020 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 }); } } Quote
Dr. McKay Posted May 20, 2020 Report Posted May 20, 2020 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. Quote
Recommended Posts
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.