mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 03:29:51 +02:00
fix: no double fetch and caching
This commit is contained in:
1 parent
6600bba58c
commit
fbde9ec64f
4 files changed
+243
-120
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { LeagueTop } from '../../commands/ratings';
|
||||
import { Region } from '../../constants/regions';
|
||||
import { patientFetch } from '../blitzkrieg/patientFetch';
|
||||
import { withCORSProxy } from '../blitzkrieg/withCORSProxy';
|
||||
import regionToRegionSubdomain from './regionToRegionSubdomain';
|
||||
|
||||
export async function getRatingsLeague(
|
||||
region: Region,
|
||||
league: number,
|
||||
usePatientFetcher = false,
|
||||
) {
|
||||
const fetcher = usePatientFetcher ? patientFetch : fetch;
|
||||
const response = await fetcher(
|
||||
withCORSProxy(
|
||||
`https://${regionToRegionSubdomain(
|
||||
region,
|
||||
)}.wotblitz.com/en/api/rating-leaderboards/league/${league}/top/`,
|
||||
),
|
||||
);
|
||||
const json = (await response.json()) as LeagueTop;
|
||||
|
||||
return json;
|
||||
}
|
||||
Reference in new issue
Block a user