Jump to content
McKay Development

xawa

Member
  • Posts

    8
  • Joined

  • Last visited

Reputation Activity

  1. Like
    xawa reacted to Dr. McKay in Cannot read property 'createOffer' of undefined   
    You're not using this properly. In JavaScript, this references the parent object of the method at call-time. So for example:
    function exampleMethod() { console.log(this.name); } let obj1 = {"name": "obj1"}; let obj2 = {"name": "obj2"}; obj1.example = exampleMethod; obj2.example = exampleMethod; obj1.example(); // "obj1" because the "parent" to this call is obj1 obj2.example(); // "obj2" because the "parent" to this call is obj2 let example = obj1.example; example(); // undefined because there is no "parent" to example() in this call So when you do getInventoryContents(foo, bar, this.createOffer), when the module receives the callback, it sees this:
    TradeOfferManager.prototype.getInventoryContents(blah, callback) { // do stuff callback(); // no parent! so "this" will not be what you expect }; What you should do instead is: getInventoryContents(foo, bar, this.createOffer.bind(this)). Using the bind method "binds" the value of this before call-time.
  2. Like
    xawa reacted to Dr. McKay in Auto Confirm Outgoing Trade Offer   
    https://github.com/DoctorMcKay/node-steamcommunity/wiki/SteamCommunity#acceptconfirmationforobjectidentitysecret-objectid-callback
×
×
  • Create New...