gigobyte / HLTV

The unofficial HLTV Node.js API
MIT License
397 stars 107 forks source link

Error or getMatchStats #294

Closed Asviix closed 4 years ago

Asviix commented 4 years ago

(node:15932) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'split' of undefined at D:\Ares\node_modules\hltv\lib\endpoints\getMatchStats.js:89:25 at step (D:\Ares\node_modules\hltv\lib\endpoints\getMatchStats.js:44:23) at Object.next (D:\Ares\node_modules\hltv\lib\endpoints\getMatchStats.js:25:53) at fulfilled (D:\Ares\node_modules\hltv\lib\endpoints\getMatchStats.js:16:58) at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:15932) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag--unhandled-rejections=strict(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1) (node:15932) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

gigobyte commented 4 years ago

Are you sure you're calling it with a real stats ID (not a match ID)? Here is the result I get for https://www.hltv.org/stats/matches/73975/fate-vs-singularity:

{
  matchPageID: 2341309,
  date: 1589191200000, 
  team1: { id: 9863, name: 'FATE', score: 1 },
  team2: { id: 6978, name: 'Singularity', score: 2 },
  event: { id: 5323, name: 'Home Sweet Home Cup 5 Closed Qualifier' },
  overview: {
    rating: { team1: 1.03, team2: 1.08 },
    firstKills: { team1: 41, team2: 48 },
    clutchesWon: { team1: 7, team2: 5 },
    mostKills: { id: 9895, name: 'mertz', value: 81 },
    mostDamage: { id: 9895, name: 'mertz', value: 96.1 },
    mostAssists: { id: 8917, name: 'niki1', value: 18 },
    mostAWPKills: { id: 9895, name: 'mertz', value: 57 },
    mostFirstKills: { id: 9895, name: 'mertz', value: 16 },
    bestRating: { id: 9895, name: 'mertz', value: 1.4 }
  },
  playerStats: {
    team1: [
      {
        id: 16410,
        name: 'Duplicate',
        kills: 73,
        hsKills: 40,
        assists: 16,
        flashAssists: 2,
        deaths: 66,
        KAST: 70.8,
        killDeathsDifference: 7,
        ADR: 86.7,
        firstKillsDifference: 0,
        rating: 1.16
      },
      {
        id: 15385,
        name: 'KalubeR',
        kills: 67,
        hsKills: 37,
        assists: 9,
        flashAssists: 2,
        deaths: 54,
        KAST: 68.5,
        killDeathsDifference: 13,
        ADR: 77.7,
        firstKillsDifference: 2,
        rating: 1.12
      },
      {
        id: 13464,
        name: 'mar',
        kills: 66,
        hsKills: 39,
        assists: 13,
        flashAssists: 3,
        deaths: 61,
        KAST: 69.7,
        killDeathsDifference: 5,
        ADR: 84,
        firstKillsDifference: -2,
        rating: 1.1
      },
      {
        id: 8917,
        name: 'niki1',
        kills: 55,
        hsKills: 30,
        assists: 23,
        flashAssists: 5,
        deaths: 69,
        KAST: 68.5,
        killDeathsDifference: -14,
        ADR: 75.4,
        firstKillsDifference: -5,
        rating: 0.97
      },
      {
        id: 20097,
        name: 'harn',
        kills: 44,
        hsKills: 7,
        assists: 8,
        flashAssists: 2,
        deaths: 55,
        KAST: 68.5,
        killDeathsDifference: -11,
        ADR: 47,
        firstKillsDifference: -2,
        rating: 0.78
      }
    ],
    team2: [
      {
        id: 9895,
        name: 'mertz',
        kills: 81,
        hsKills: 20,
        assists: 17,
        flashAssists: 7,
        deaths: 60,
        KAST: 74.2,
        killDeathsDifference: 21,
        ADR: 96.1,
        firstKillsDifference: 9,
        rating: 1.4
      },
      {
        id: 16718,
        name: 'Fessor',
        kills: 70,
        hsKills: 54,
        assists: 13,
        flashAssists: 4,
        deaths: 60,
        KAST: 74.2,
        killDeathsDifference: 10,
        ADR: 80.6,
        firstKillsDifference: 1,
        rating: 1.17
      },
      {
        id: 3820,
        name: 'TOBIZ',
        kills: 55,
        hsKills: 26,
        assists: 17,
        flashAssists: 3,
        deaths: 61,
        KAST: 71.9,
        killDeathsDifference: -6,
        ADR: 69,
        firstKillsDifference: 2,
        rating: 0.99
      },
      {
        id: 17956,
        name: 'Jabbi',
        kills: 47,
        hsKills: 28,
        assists: 20,
        flashAssists: 4,
        deaths: 68,
        KAST: 75.3,
        killDeathsDifference: -21,
        ADR: 65.6,
        firstKillsDifference: -1,
        rating: 0.92
      },
      {
        id: 11257,
        name: 'Celrate',
        kills: 52,
        hsKills: 26,
        assists: 8,
        flashAssists: 2,
        deaths: 56,
        KAST: 73,
        killDeathsDifference: -4,
        ADR: 58.5,
        firstKillsDifference: -4,
        rating: 0.92
      }
    ]
  }
}
Asviix commented 4 years ago

Indeed that was the error, thanks for the help !