jeudi 2 avril 2020

Why steam web api returns undefined json value node js

Hello these code does request to Steam Web API

const request = require("request");
request({
    url: "https://api.steampowered.com/IEconService/GetTradeOffers/v1/?key=MYAPIKEY&get_sent_offers=1&active_only=1&format=json",
json: true
}, (err, responser, body) => {
    console.log(body.response['trade_offers_sent']);
});

And this is what it returns:

{
  trade_offers_sent: [
    {
      tradeofferid: '3974708687',
      accountid_other: 82613664,
      message: 'test message',
      expiration_time: 1587017229,
      trade_offer_state: 9,
      items_to_give: [Array],
      is_our_offer: true,
      time_created: 1585807629,
      time_updated: 1585807629,
      from_real_time_trade: false,
      escrow_end_date: 0,
      confirmation_method: 2
    }
  ]
}

But when i'm trying to get value of accountid_other this way:

console.log(body.response['trade_offers_sent'].accountid_other);

it returns undefined




Aucun commentaire:

Enregistrer un commentaire