bttmly / nba

Node.js client for nba.com API endpoints

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

teamPlayerDashboard return 400 with right parameter

florianpeninon opened this issue · comments

Hi there, when trying to use the teamPlayerDashboard endpoint I encounter a 400 bad request throwing The field TeamID must be between 1 and 2147483647. No matter the teamID I use I get the same response.

Here is my call

nba.stats.teamPlayerDashboard({
  teamID: 1610612749,
  SeasonType: "Regular Season"
}).then(function(data) {
  fs.writeFile('team-player-dashboard.json', JSON.stringify(data, null, 2), function(err) {
    if (err) throw err
    console.log('team-player-dashboard.json saved!')
  })
}).catch(function(err) {
  console.log(err)
})

this this test failing on your end?

oh! you're supplying a teamId but not a TeamId.

@brandly oh, good catch! Working now!

Yeah urgh... I've gone back and forth several times on how to handle parameter capitalization. On the one hand, it's simpler to just use the capitalization the NBA wants. On the other hand, it's not idiomatic in JS. One solution might be a util that can translate them intelligently -- previously the keys were uppercased automatically which seemed to confuse people. So an opt-in util probably would be best

A better solution would be to figure out the required parameters for endpoints and do checks on them at the time a request is made.