const s = new URLSearchParams(); s.append("grant_type", "client_credentials"); const spotify_response = await fetch("https://accounts.spotify.com/api/token", { headers: { "Authorization": `Basic ${Buffer.from(process.env.SPOTIFY_CLIENT + ":" + process.env.SPOTIFY_SECRET).toString('base64')}`, "Content-Type": "application/x-www-form-urlencoded" }, body: s.toString(), method: "POST" }).then(res => res.json()); const sptToken = spotify_response.access_token; export async function spotifyFetch(url: string): Promise { return fetch("https://api.spotify.com/v1" + url, { headers: { "Authorization": `Bearer ${sptToken}` } }).then(res => res.json()); }