bgrnwd / fotmob

:soccer: An unofficial JavaScript/TypeScript client for the FotMob API
MIT License
127 stars 16 forks source link

[BUG] Invalid value for key Header #447

Open Cabezaa opened 5 months ago

Cabezaa commented 5 months ago

Is there an existing issue for this?

Current Behavior

E:\Proyectos\scrap-fotmob\node_modules\fotmob\dist\cjs\types\match-details.js:807 throw Error('Invalid value${keyText}${parentText}. Expected ${prettyTyp} but got ${JSON.stringify(val)}');

Error: Invalid value for key "header" on MatchDetails. Expected an optional object but got {"teams":[{"name":"Barcelona","id":8634,"score":2,"imageUrl":"https://images.fotmob.com/image_resources/logo/teamlogo/8634_small.png","pageUrl":"/teams/8634/overview/barcelona","fifaRank":null},{"name":"Bayern München","id":9823,"score":8,"imageUrl":"https://images.fotmob.com/image_resources/logo/teamlogo/9823_small.png","pageUrl":"/teams/9823/overview/bayern-munchen","fifaRank":null}],"status":{"utcTime":"2020-08-14T19:00:00.000Z","homeRedCards":[],"awayRedCards":[],"finished":true,"started":true,"cancelled":false,"scoreStr":"2 - 8","reason":{"short":"FT","shortKey":"fulltime_short","long":"Full-Time","longKey":"finished"},"whoLostOnPenalties":null,"whoLostOnAggregated":""},"events":{"homeTeamGoals":{"Alaba":[{"reactKey":"7Goal121633undefinedtrue","timeStr":7,"type":"Goal","time":7,"overloadTime":null,"eventId":7219005,"player":{"id":121633,"name":"David Alaba","profileUrl":"/players/121633/david-alaba"},"profileUrl":"/players/121633/david-alaba","overloadTimeStr":false,"isHome":true,"ownGoal":true,"goalDescription":"Own goal","goalDescriptionKey":"owngoal","suffix":"OG","suffixKey":"own_goal_short","isPenaltyShootoutEvent":false,"nameStr":"David Alaba","firstName":"David","lastName":"Alaba","fullName":"David Alaba","playerId":121633,"newScore":[1,1],"penShootoutScore":null,"shotmapEvent":null,"assistStr":null,"assistProfileUrl":null}],"Suárez":[{"reactKey":"57Goal40636undefinedtrue","timeStr":57,"type":"Goal","time":57,"overloadTime":null,"eventId":7219141,"player":{"id":40636,"name":"Luis Suárez","profileUrl":"/players/40636/luis-suarez"},"profileUrl":"/players/40636/luis-suarez","overloadTimeStr":false,"isHome":true,"ownGoal":null,"goalDescription":null,"goalDescriptionKey":null,"suffix":null,"suffixKey":null,"isPenaltyShootoutEvent":false,"nameStr":"Luis Suárez","firstName":"Luis","lastName":"Suárez","fullName":"Luis Suárez","playerId":40636,"newScore":[2,4],"penShootoutScore":null,"shotmapEvent":null,"assistStr":"assist by Jordi Alba","assistProfileUrl":"/players/150739/jordi-alba","assistPlayerId":150739,"assistKey":"assist_by","assistInput":"Jordi Alba"}]},"awayTeamGoals":{"Müller":[{"reactKey":"4Goal116772undefinedfalse","timeStr":4,"type":"Goal","time":4,"overloadTime":null,"eventId":7218999,"player":{"id":116772,"name":"Thomas Müller","profileUrl":"/players/116772/thomas-muller"},"profileUrl":"/players/116772/thomas-muller","overloadTimeStr":false,"isHome":false,"ownGoal":null,"goalDescription":null,"goalDescriptionKey":null,"suffix":null,"suffixKey":null,"isPenaltyShootoutEvent":false,"nameStr":"Thomas Müller","firstName":"Thomas","lastName":"Müller","fullName":"Thomas Müller","playerId":116772,"newScore":[0,1],"penShootoutScore":null,"shotmapEvent":null,"assistStr":"assist by Robert Lewandowski","assistProfileUrl":"/players/93447/robert-lewandowski","assistPlayerId":93447,"assistKey":"assist_by","assistInput":"Robert Lewandowski"},{"reactKey":"31Goal116772undefinedfalse","timeStr":31,"type":"Goal","time":31,"overloadTime":null,"eventId":7219040,"player":{"id":116772,"name":"Thomas Müller","profileUrl":"/players/116772/thomas-muller"},"profileUrl":"/players/116772/thomas-muller","overloadTimeStr":false,"isHome":false,"ownGoal":null,"goalDescription":null,"goalDescriptionKey":null,"suffix":null,"suffixKey":null,"isPenaltyShootoutEvent":false,"nameStr":"Thomas Müller","firstName":"Thomas","lastName":"Müller","fullName":"Thomas Müller","playerId":116772,"newScore":[1,4],"penShootoutScore":null,"shotmapEvent":null,"assistStr":"assist by Joshua Kimmich","assistProfileUrl":"/players/460632/joshua-kimmich","assistPlayerId":460632,"assistKey":"assist_by","assistInput":"Joshua Kimmich"}],"Perisic":[{"reactKey":"22Goal163670undefinedfalse","timeStr":22,"type":"Goal","time":22,"overloadTime":null,"eventId":7219022,"player":{"id":163670,"name":"Ivan Perisic","profileUrl":"/players/163670/ivan-perisic"},"profileUrl":"/players/163670/ivan-perisic","overloadTimeStr":false,"isHome":false,"ownGoal":null,"goalDescription":null,"goalDescriptionKey":null,"suffix":null,"suffixKey":null,"isPenaltyShootoutEvent":false,"nameStr":"Ivan Perisic","firstName":"Ivan","lastName":"Perisic","fullName":"Ivan Perisic","playerId":163670,"newScore":[1,2],"penShootoutScore":null,"shotmapEvent":null,"assistStr":"assist by Serge Gnabry","assistProfileUrl":"/players/385437/serge-gnabry","assistPlayerId":385437,"assistKey":"assist_by","assistInput":"Serge Gnabry"}],"Gnabry":[{"reactKey":"27Goal385437undefinedfalse","timeStr":27,"type":"Goal","time":27,"overloadTime":null,"eventId":7219033,"player":{"id":385437,"name":"Serge Gnabry","profileUrl":"/players/385437/serge-gnabry"},"profileUrl":"/players/385437/serge-gnabry","overloadTimeStr":false,"isHome":false,"ownGoal":null,"goalDescription":null,"goalDescriptionKey":null,"suffix":null,"suffixKey":null,"isPenaltyShootoutEvent":false,"nameStr":"Serge Gnabry","firstName":"Serge","lastName":"Gnabry","fullName":"Serge Gnabry","playerId":385437,"newScore":[1,3],"penShootoutScore":null,"shotmapEvent":null,"assistStr":"assist by Leon Goretzka","assistProfileUrl":"/players/343748/leon-goretzka","assistPlayerId":343748,"assistKey":"assist_by","assistInput":"Leon Goretzka"}],"Kimmich":[{"reactKey":"63Goal460632undefinedfalse","timeStr":63,"type":"Goal","time":63,"overloadTime":null,"eventId":7219157,"player":{"id":460632,"name":"Joshua Kimmich","profileUrl":"/players/460632/joshua-kimmich"},"profileUrl":"/players/460632/joshua-kimmich","overloadTimeStr":false,"isHome":false,"ownGoal":null,"goalDescription":null,"goalDescriptionKey":null,"suffix":null,"suffixKey":null,"isPenaltyShootoutEvent":false,"nameStr":"Joshua Kimmich","firstName":"Joshua","lastName":"Kimmich","fullName":"Joshua Kimmich","playerId":460632,"newScore":[2,5],"penShootoutScore":null,"shotmapEvent":null,"assistStr":"assist by Alphonso Davies","assistProfileUrl":"/players/751202/alphonso-davies","assistPlayerId":751202,"assistKey":"assist_by","assistInput":"Alphonso Davies"}],"Lewandowski":[{"reactKey":"82Goal93447undefinedfalse","timeStr":82,"type":"Goal","time":82,"overloadTime":null,"eventId":7219213,"player":{"id":93447,"name":"Robert Lewandowski","profileUrl":"/players/93447/robert-lewandowski"},"profileUrl":"/players/93447/robert-lewandowski","overloadTimeStr":false,"isHome":false,"ownGoal":null,"goalDescription":null,"goalDescriptionKey":null,"suffix":null,"suffixKey":null,"isPenaltyShootoutEvent":false,"nameStr":"Robert Lewandowski","firstName":"Robert","lastName":"Lewandowski","fullName":"Robert Lewandowski","playerId":93447,"newScore":[2,6],"penShootoutScore":null,"shotmapEvent":null,"assistStr":"assist by Philippe Coutinho","assistProfileUrl":"/players/184536/philippe-coutinho","assistPlayerId":184536,"assistKey":"assist_by","assistInput":"Philippe Coutinho"}],"Coutinho":[{"reactKey":"85Goal184536undefinedfalse","timeStr":85,"type":"Goal","time":85,"overloadTime":null,"eventId":7219242,"player":{"id":184536,"name":"Philippe Coutinho","profileUrl":"/players/184536/philippe-coutinho"},"profileUrl":"/players/184536/philippe-coutinho","overloadTimeStr":false,"isHome":false,"ownGoal":null,"goalDescription":null,"goalDescriptionKey":null,"suffix":null,"suffixKey":null,"isPenaltyShootoutEvent":false,"nameStr":"Philippe Coutinho","firstName":"Philippe","lastName":"Coutinho","fullName":"Philippe Coutinho","playerId":184536,"newScore":[2,7],"penShootoutScore":null,"shotmapEvent":null,"assistStr":"assist by Thomas Müller","assistProfileUrl":"/players/116772/thomas-muller","assistPlayerId":116772,"assistKey":"assist_by","assistInput":"Thomas Müller"},{"reactKey":"89Goal184536undefinedfalse","timeStr":89,"type":"Goal","time":89,"overloadTime":null,"eventId":7219246,"player":{"id":184536,"name":"Philippe Coutinho","profileUrl":"/players/184536/philippe-coutinho"},"profileUrl":"/players/184536/philippe-coutinho","overloadTimeStr":false,"isHome":false,"ownGoal":null,"goalDescription":null,"goalDescriptionKey":null,"suffix":null,"suffixKey":null,"isPenaltyShootoutEvent":false,"nameStr":"Philippe Coutinho","firstName":"Philippe","lastName":"Coutinho","fullName":"Philippe Coutinho","playerId":184536,"newScore":[2,8],"penShootoutScore":null,"shotmapEvent":null,"assistStr":"assist by Lucas Hernández","assistProfileUrl":"/players/504606/lucas-hernandez","assistPlayerId":504606,"assistKey":"assist_by","assistInput":"Lucas Hernández"}]}}} at invalidValue (E:\Proyectos\scrap-fotmob\node_modules\fotmob\dist\cjs\types\match-details.js:807:11) at transformUnion (E:\Proyectos\scrap-fotmob\node_modules\fotmob\dist\cjs\types\match-details.js:860:16) at transform (E:\Proyectos\scrap-fotmob\node_modules\fotmob\dist\cjs\types\match-details.js:921:15) at E:\Proyectos\scrap-fotmob\node_modules\fotmob\dist\cjs\types\match-details.js:894:32 at Array.forEach (<anonymous>) at transformObject (E:\Proyectos\scrap-fotmob\node_modules\fotmob\dist\cjs\types\match-details.js:889:43) at transform (E:\Proyectos\scrap-fotmob\node_modules\fotmob\dist\cjs\types\match-details.js:925:23) at cast (E:\Proyectos\scrap-fotmob\node_modules\fotmob\dist\cjs\types\match-details.js:933:12) at toMatchDetails (E:\Proyectos\scrap-fotmob\node_modules\fotmob\dist\cjs\types\match-details.js:160:16) at Fotmob.<anonymous> (E:\Proyectos\scrap-fotmob\node_modules\fotmob\dist\cjs\fotmob.js:56:24)

Expected Behavior

For Fotmob v2.4.0, The await fotmob.getMatchDetails(3363666); should return an object with the match details

Steps To Reproduce

  1. Create a new project for TS/JS
  2. Install the Fotmob Library
  3. Call the getMatchDetails method with some matchId
  4. Get the error

Environment

- OS: Windows 11
- Node: v18.18.0
- npm: 9.8.1

Version

1.0.0

Anything else?

No response

bgrnwd commented 5 months ago

Thanks for reporting this, I'll see if I can reproduce it.

ItamarShDev commented 4 months ago

This is probably due to a a schema diff with the type. We can make the code convert to type or json on failures, instead of throwing. wdyt @bgrnwd ?

bgrnwd commented 4 months ago

I think attempting a conversion makes sense

ItamarShDev commented 2 months ago

this error should be closed. is it still occuring?