export type GetApiYtMusicSearchArgs = {q: string}; export type GetApiYtMusicSearchOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Search Track * * GET /yt-music/search */ export const getApiYtMusicSearch = async (args: GetApiYtMusicSearchArgs, options?: GetApiYtMusicSearchOptions) => { const {baseUrl = "https://api.paxsenix.org", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.q != null) query.append("q", String(args.q)) const url = `${baseUrl.replace(/\/+$/, '')}/yt-music/search${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };