Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | 42x 42x 46x 4x | import type { ServerApiContext } from "types/serverContext"; import { handleJsonResponse } from "utils"; import { callSpotifyApi } from "utils/spotifyCalls"; export enum TopType { TRACKS = "tracks", ARTISTS = "artists", } export async function getMyTop<T extends TopType>( type: TopType | T, limit?: number, time_range?: "medium_term" | "short_term" | "long_term", context?: ServerApiContext ): Promise< T extends TopType.TRACKS ? SpotifyApi.UsersTopTracksResponse | null : SpotifyApi.UsersTopArtistsResponse | null > { const res = await callSpotifyApi({ endpoint: `/me/top/${type}?time_range=${time_range ?? "short_term"}&limit=${ limit ?? 10 }`, method: "GET", context, }); return handleJsonResponse< T extends TopType.TRACKS ? SpotifyApi.UsersTopTracksResponse : SpotifyApi.UsersTopArtistsResponse >(res); } |