xDimGG / node-steamapi

An object-oriented Steam API wrapper for Node.js developers.
https://www.npmjs.com/package/steamapi
181 stars 42 forks source link

Throw appropriate error in `getUserOwnedGames` when the user's game details are private #28

Closed chescos closed 3 years ago

chescos commented 3 years ago

When the game details of a user are not private, the response looks like this:

{
  "response": {
    "game_count": 1,
    "games": [
      {
        "appid": 220,
        "playtime_forever": 125,
        "playtime_windows_forever": 0,
        "playtime_mac_forever": 0,
        "playtime_linux_forever": 0
      }
    ]
  }
}

When the game details are private, however, the response looks like this:

{"response":{}}

In both cases, the HTTP status code is 200. That's why currently, you get this error when the profile is private: TypeError: Cannot read property 'map' of undefined. This PR throws a No games found error instead.