fix beatsaviour api url

This commit is contained in:
Lee 2023-10-17 23:31:58 +01:00
parent c17c2a8b76
commit e6f510cec3

@ -1,18 +1,20 @@
import {default as createQueue, PRIORITY} from '../http-queue'; import ssrConfig from "../../../ssr-config";
import {substituteVars} from "../../../utils/format"; import { substituteVars } from "../../../utils/format";
import { default as createQueue, PRIORITY } from "../http-queue";
const BEATSAVIOR_API_URL = '/cors/beat-savior'; const BEATSAVIOR_API_URL = "https://www.beatsavior.io/api/livescores/player/";
const PLAYER_URL = BEATSAVIOR_API_URL + '/${playerId}'; const PLAYER_URL = ssrConfig.proxy + "/" + BEATSAVIOR_API_URL + "/${playerId}";
export default (options = {}) => { export default (options = {}) => {
const queue = createQueue(options); const queue = createQueue(options);
const {fetchJson, fetchHtml, ...queueToReturn} = queue; const { fetchJson, fetchHtml, ...queueToReturn } = queue;
const player = async (playerId, priority = PRIORITY.FG_LOW, options = {}) => fetchJson(substituteVars(PLAYER_URL, {playerId}), options, priority) const player = async (playerId, priority = PRIORITY.FG_LOW, options = {}) =>
fetchJson(substituteVars(PLAYER_URL, { playerId }), options, priority);
return { return {
player, player,
...queueToReturn, ...queueToReturn,
} };
} };