asbeane / mlb-stats-api

Node.js Library for making requests to the MLB Stats API
MIT License
35 stars 15 forks source link

getGame() gives error #20

Closed bradmallett closed 1 year ago

bradmallett commented 1 year ago

When calling getGame like this:

const res = await mlbStats.getGame({ pathParams: { gamePk: 717754 }});
const game = await res.json()

I'm getting this error:

{
  messageNumber: 14,
  message: "Request method 'GET' not supported",
  timestamp: '2023-06-16T21:37:06.585597829Z',
  traceId: null
}

Am I missing something? I'm trying to follow your readme

Iliannnn commented 1 year ago

The function you're using seems to be pointing to the wrong endpoint, /game/{gamePk}, which doesn't exist. It looks like you want to fetch data from the live feed endpoint, /game/{gamePk}/feed/live, instead. To do this, you should use the getGameFeed() function.

I noticed a mistake in the README where it says you can get the live feed using the getGame() function, but that's not correct. I'll fix this and open a pull request to update the README and remove the incorrect function.

bradmallett commented 1 year ago

Ok, so for example if I wanted only the teams with the league id of 103, I would think I would do this: getTeams({params: { leagueId: 103 } }); Doesn't seem to work. I'm learning, you can probably tell, but am I doing this correctly?

Iliannnn commented 1 year ago

Use the leagueIds parameter:

getTeams({ params: { leagueIds: 103 } });

For additional information, access a minimal version of the private documentation by using the JSON from here in SwaggerEditor. Let me know if you have more questions.