Jump to content


Photo

TypeError: Cannot read property 'appid' of undefined

node.js node-steam-tradeoffer-manager

  • Please log in to reply
8 replies to this topic

#1 yoba

yoba

    Member

  • Member
  • PipPip
  • 11 posts

Posted 12 March 2017 - 11:15 AM

 Please help with my problem. I do not know why the 'appid' is not defined

 

Stack trace:

Logged into Steam
/Users/user/Documents/node/steam/node_modules/steam-tradeoffer-manager/lib/classes/TradeOffer.js:419
	if (typeof details.appid === 'undefined' || typeof details.contextid === 'undefined' || (typeof details.assetid === 'undefined' && typeof details.id === 'undefined')) {
	                  ^

TypeError: Cannot read property 'appid' of undefined
    at addItem (/Users/user/Documents/node/steam/node_modules/steam-tradeoffer-manager/lib/classes/TradeOffer.js:419:20)
    at TradeOffer.addTheirItem (/Users/user/Documents/node/steam/node_modules/steam-tradeoffer-manager/lib/classes/TradeOffer.js:374:9)
    at manager.loadUserInventory (/Users/user/Documents/node/steam/project4.js:80:12)
    at SteamCommunity.<anonymous> (/Users/user/Documents/node/steam/node_modules/steamcommunity/components/users.js:331:5)
    at Request._callback (/Users/user/Documents/node/steam/node_modules/steamcommunity/components/http.js:67:15)
    at Request.self.callback (/Users/user/Documents/node/steam/node_modules/request/request.js:188:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/Users/user/Documents/node/steam/node_modules/request/request.js:1171:10)
    at emitOne (events.js:96:13)

Code:

function sendRandomItem() {

	const partner = 'partner_code';
	const appid = 730;
	const contextid = 2;
	const offer = manager.createOffer(partner);

	manager.loadInventory(appid, contextid, true, (err, myInv) => {

		if (err) {
			console.log(err);
		} else {
			const myItem = myInv[Math.floor(Math.random() * myInv.length - 1)];
			offer.addMyItem(myItem);

			manager.loadUserInventory(partner, appid, contextid, true, (err, theirInv) => {
				if (err) {
					console.log(err);
				} else {
					const theirItem = theirInv[Math.floor(Math.random() * theirInv.length - 1)];
					offer.addTheirItem(theirItem);

					offer.setMessage(`Will you trade your ${theirItem.name} for my ${myItem.name}?`);
					offer.send((err, status) => {
						if (err) {
							console.log(err);
						} else {
							console.log(`Sent offer. Status: ${status}.`);
						}
					});
				}
			});
		}
	});
}



#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,652 posts

Posted 12 March 2017 - 03:54 PM

Looks like one of the items you're trying to add is undefined. Perhaps someone's inventory is empty?



#3 yoba

yoba

    Member

  • Member
  • PipPip
  • 11 posts

Posted 12 March 2017 - 04:26 PM

No, inventory on both accounts is not empty.



#4 yoba

yoba

    Member

  • Member
  • PipPip
  • 11 posts

Posted 12 March 2017 - 07:53 PM

Logged into Steam
{ Error: There was an error sending your trade offer.  Please try again later. (15)
    at Object.exports.makeAnError (/Users/code/Documents/node/steam/node_modules/steam-tradeoffer-manager/lib/helpers.js:12:12)
    at SteamCommunity.manager._community.httpRequestPost (/Users/code/Documents/node/steam/node_modules/steam-tradeoffer-manager/lib/classes/TradeOffer.js:513:12)
 
I do not understand why I get this error. What am I doing wrong? I already read about this error. But there are no restrictions on my accounts, what could be the problem?


#5 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 1,652 posts

Posted 12 March 2017 - 10:07 PM

https://steamerrors.com/15



#6 snakj

snakj

    Newbie

  • Member
  • Pip
  • 1 posts

Posted 03 September 2017 - 07:03 PM

yoba did you solved your problem? i'm having the same issue. already changed to other accounts and problem still alive...



#7 Andrei Elvis

Andrei Elvis

    Member

  • Member
  • PipPip
  • 12 posts

Posted 27 September 2017 - 07:08 AM

When you add items to the offer (with .addMyItem and .addTheirItem) you need to specify appid and contextid of items.

So, instead of

offer.addMyItem(myItem);

Replace with:

offer.addMyItem({
    'assetid': myItem.assetid,
    'appid': appid,
    'contextid': contextid
});

Same for

offer.addTheirItem(theirItem);

Replace with:

offer.addTheirItem({
    'assetid': theirItem.assetid,
    'appid': appid,
    'contextid': contextid
});


#8 woepertjes

woepertjes

    Newbie

  • Member
  • Pip
  • 7 posts
  • LocationThe Netherlands

Posted 20 March 2018 - 03:06 PM

Andrei Elvis, you say you have to specify the appid and contextid of items, does the same rule apply to "addTheirItems()"? Here i am pointing to the S at the end of that function. Thanks for letting me know <3



#9 Franz Darelle

Franz Darelle

    Newbie

  • Member
  • Pip
  • 2 posts

Posted 09 April 2018 - 05:31 AM

you guys have answer for this? cant get it right

 

 offer.addMyItem({
        'assetid': myItem.assetid,
        'appid': appid,
        'contextid': contextid
    });

      manager.loadUserInventory(
        partner,
        appid,
        contextid,
        true,
        (err, theirInv) => {
          if (err) {
            console.log(err);
          } else {
            const theirItem =
              theirInv[Math.floor(Math.random() * theirInv.length - 1)];
            offer.addTheirItem({
              'assetid': theirItem.assetid,
              'appid': appid,
              'contextid': contextid
          });






Also tagged with one or more of these keywords: node.js, node-steam-tradeoffer-manager

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users