Fix MLB standings 406 error and refactor ESPN adapter shared code #62
3 changed files with 6 additions and 3 deletions
|
|
@ -4,6 +4,7 @@ import {
|
||||||
parseConferenceRank,
|
parseConferenceRank,
|
||||||
sortByWinLoss,
|
sortByWinLoss,
|
||||||
statsMap,
|
statsMap,
|
||||||
|
type EspnStandingsResponse,
|
||||||
} from "./espn";
|
} from "./espn";
|
||||||
|
|
||||||
const MLB_STANDINGS_URL =
|
const MLB_STANDINGS_URL =
|
||||||
|
|
@ -30,7 +31,7 @@ export class MlbStandingsAdapter implements StandingsSyncAdapter {
|
||||||
throw new Error(`MLB standings API returned ${response.status}: ${response.statusText}`);
|
throw new Error(`MLB standings API returned ${response.status}: ${response.statusText}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const json = await response.json();
|
const json = (await response.json()) as EspnStandingsResponse;
|
||||||
const flattened = flattenEspnStandings(json);
|
const flattened = flattenEspnStandings(json);
|
||||||
|
|
||||||
if (flattened.length === 0) {
|
if (flattened.length === 0) {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ import {
|
||||||
flattenEspnStandings,
|
flattenEspnStandings,
|
||||||
parseConferenceRank,
|
parseConferenceRank,
|
||||||
statsMap,
|
statsMap,
|
||||||
|
type EspnStandingsResponse,
|
||||||
} from "./espn";
|
} from "./espn";
|
||||||
|
|
||||||
const MLS_STANDINGS_URL =
|
const MLS_STANDINGS_URL =
|
||||||
|
|
@ -28,7 +29,7 @@ export class MlsStandingsAdapter implements StandingsSyncAdapter {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const json = await response.json();
|
const json = (await response.json()) as EspnStandingsResponse;
|
||||||
const flattened = flattenEspnStandings(json);
|
const flattened = flattenEspnStandings(json);
|
||||||
|
|
||||||
if (flattened.length === 0) {
|
if (flattened.length === 0) {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import {
|
||||||
parseConferenceRank,
|
parseConferenceRank,
|
||||||
sortByWinLoss,
|
sortByWinLoss,
|
||||||
statsMap,
|
statsMap,
|
||||||
|
type EspnStandingsResponse,
|
||||||
} from "./espn";
|
} from "./espn";
|
||||||
|
|
||||||
const NBA_STANDINGS_URL =
|
const NBA_STANDINGS_URL =
|
||||||
|
|
@ -16,7 +17,7 @@ export class NbaStandingsAdapter implements StandingsSyncAdapter {
|
||||||
throw new Error(`NBA standings API returned ${response.status}: ${response.statusText}`);
|
throw new Error(`NBA standings API returned ${response.status}: ${response.statusText}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const json = await response.json();
|
const json = (await response.json()) as EspnStandingsResponse;
|
||||||
const flattened = flattenEspnStandings(json);
|
const flattened = flattenEspnStandings(json);
|
||||||
|
|
||||||
if (flattened.length === 0) {
|
if (flattened.length === 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue