Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'player_stats' of undefined #70

Closed
cjhaviland opened this issue Feb 26, 2021 · 6 comments
Closed

Cannot read property 'player_stats' of undefined #70

cjhaviland opened this issue Feb 26, 2021 · 6 comments

Comments

@cjhaviland
Copy link

In trying to use the yf.player.stats resource and giving a player_key and a week I am getting this error. Checking out the return data I see that you try to grab data.fantasy_content.player[1] but in my return is only 1 item.

For context I am looking at 2019 data for player_key 388.p.8859 and week 1.

@cjhaviland
Copy link
Author

Here is the player object that is returned for Week 1. Doesn't look like that are any stats there and I am not sure why. Using the link returned from this API for my 2019 league I see stats for Week 1.

"player": [
        [
            {
                "player_key": "388.p.8859"
            },
            {
                "player_id": "8859"
            },
            {
                "name": {
                    "full": "Wil Myers",
                    "first": "Wil",
                    "last": "Myers",
                    "ascii_first": "Wil",
                    "ascii_last": "Myers"
                }
            },
            {
                "editorial_player_key": "mlb.p.8859"
            },
            {
                "editorial_team_key": "mlb.t.25"
            },
            {
                "editorial_team_full_name": "San Diego Padres"
            },
            {
                "editorial_team_abbr": "SD"
            },
            {
                "uniform_number": "4"
            },
            {
                "display_position": "1B,3B,OF"
            },
            {
                "headshot": {
                    "url": "https://s.yimg.com/iu/api/res/1.2/FJdAGsMAIyULlJ8e_ZLjRA--~C/YXBwaWQ9eXNwb3J0cztjaD0yMzM2O2NyPTE7Y3c9MTc5MDtkeD04NTc7ZHk9MDtmaT11bGNyb3A7aD02MDtxPTEwMDt3PTQ2/https://s.yimg.com/xe/i/us/sp/v/mlb_cutout/players_l/10012020/8859.png",
                    "size": "small"
                },
                "image_url": "https://s.yimg.com/iu/api/res/1.2/FJdAGsMAIyULlJ8e_ZLjRA--~C/YXBwaWQ9eXNwb3J0cztjaD0yMzM2O2NyPTE7Y3c9MTc5MDtkeD04NTc7ZHk9MDtmaT11bGNyb3A7aD02MDtxPTEwMDt3PTQ2/https://s.yimg.com/xe/i/us/sp/v/mlb_cutout/players_l/10012020/8859.png"
            },
            {
                "is_undroppable": "0"
            },
            {
                "position_type": "B"
            },
            [],
            {
                "eligible_positions": [
                    {
                        "position": "1B"
                    },
                    {
                        "position": "3B"
                    },
                    {
                        "position": "CF"
                    },
                    {
                        "position": "CI"
                    },
                    {
                        "position": "IF"
                    },
                    {
                        "position": "LF"
                    },
                    {
                        "position": "OF"
                    },
                    {
                        "position": "RF"
                    }
                ]
            },
            [],
            [],
            []
        ]
    ],

@whatadewitt
Copy link
Owner

Let me take a look tonight and I'll get back to you!! Can you check to see if it's returned properly on the sandbox site in the meantime?

@whatadewitt
Copy link
Owner

Piss... this is definitely a bug, but I am so sure I had just done some work here... that said, you're right, the data from Yahoo! is not coming back as expected. I will inspect more and let you know.

@whatadewitt
Copy link
Owner

whatadewitt commented Mar 6, 2021

... and that was easy... there's been an (undocumented) change to the Yahoo! API where I have to remove the "type=week" from the url... pushing a fix up later tonight (have to run to a family engagement now)

whatadewitt pushed a commit that referenced this issue Mar 7, 2021
whatadewitt added a commit that referenced this issue Mar 7, 2021
fixing issue #70
@whatadewitt
Copy link
Owner

Should be resolved now with 4.1.3 -- what a pain... thanks for submitting this issue!

@cjhaviland
Copy link
Author

Oh wow! Thanks for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants