Giter Club home page Giter Club logo

nhl-api's People

Contributors

gretzky avatar lucacataldo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nhl-api's Issues

getPlayers endpoint returns an error

This is the request I'm running:

  nhl.getPlayer({
    name: "wayne"
  }).then(players => {
    console.log('huh', players)
    res.status(200).json({ players })
  }).catch(error => {
    console.log('error ', error)
    res.status(500)
  })

Basically just trying to fetch a player using just the name property โ€“ but I'm getting a type error. Any help is much appreciated.

 TypeError: Cannot read property 'some' of undefined
    at /Users/taylorbourne/_PROJECTS/_NAMESAUCER/_WEB/namesaucer/node_modules/@nhl-api/client/lib/src/util/index.js:26:23
    at Array.filter (<anonymous>)
    at Object.exports.getId (/Users/taylorbourne/_PROJECTS/_NAMESAUCER/_WEB/namesaucer/node_modules/@nhl-api/client/lib/src/util/index.js:25:27)
    at Object.exports.handleUrl (/Users/taylorbourne/_PROJECTS/_NAMESAUCER/_WEB/namesaucer/node_modules/@nhl-api/client/lib/src/util/index.js:45:23)
    at Object.<anonymous> (/Users/taylorbourne/_PROJECTS/_NAMESAUCER/_WEB/namesaucer/node_modules/@nhl-api/client/lib/src/player/index.js:15:32)
    at Generator.next (<anonymous>)
    at /Users/taylorbourne/_PROJECTS/_NAMESAUCER/_WEB/namesaucer/node_modules/@nhl-api/client/lib/src/player/index.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/taylorbourne/_PROJECTS/_NAMESAUCER/_WEB/namesaucer/node_modules/@nhl-api/client/lib/src/player/index.js:4:12)
    at Object.getPlayer (/Users/taylorbourne/_PROJECTS/_NAMESAUCER/_WEB/namesaucer/node_modules/@nhl-api/client/lib/src/player/index.js:14:12)

Curious about methodology for player list

Hi Gretzky!

First of all great work, i love what you have done and I have not ran into any issues yet. However, I am quite new with the NHL API and thankfully came accros your work. I was wondering if you could explain to me the methodology you used to write this list of players with their matching ID. With my brief experience with the NHL API I seemed to be only able to retrieve active players ID through their respective teams. How did you manage to get the ID's of non active players?

Thanks

Use of the

To Recreate

Make a call to the .getTeams() method similar to the following:

nhlApi.getTeams({
	expand: "stats"
});

Use of the "expand" option on .getTeams() produces undesired results, can cause requests to fail

To Recreate

Call .getTeams() without specifying a team (via name or id) and use the expand option

Example:

nhl.getTeams({
	expand: "stats"
});

Here, the desired output would be an array of all teams and their current season stats, however the request will fail with a 400 code.

Possible causes

In the getTeams() function there is an if...else block that checks for the inclusion of "roster" or "stats" in options.expand. If they do exist, /roster and /stats are appended to the baseUrl accordingly. If a single team was selected via an id or name, this partially works as the roster or stats for that team are returned albeit without the other team data, but if more than one team is requested these routes do not exist on the NHL's API, leading to the 400 response.

Possible Solution

Don't add the /stats or /roster paths to the baseUrl and simply let url = baseUrl. The if statement that follows and checks for the options.expand property appends the appropriate query to the request

This also means that the expand option works as it is intended to and expands on the information provided in comparison to its omission.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.