Skip to content

Instantly share code, notes, and snippets.

@Yidaotus
Created February 25, 2022 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yidaotus/d1f5da05eca4ec7ad87e4284a8daae9c to your computer and use it in GitHub Desktop.
Save Yidaotus/d1f5da05eca4ec7ad87e4284a8daae9c to your computer and use it in GitHub Desktop.
Fetch Function
const fetchSpotifyPlayer = async () => {
const URL = "./.netlify/functions/CurrentlyPlaying";
const OPTIONS = {
method: "GET",
headers: {
Accept: "application/json",
"Content-Type": "application/json;charset=UTF-8",
},
};
const response = await fetch(URL, OPTIONS);
if (!response.ok) {
throw new Error(response.statusText);
}
const data: CurrentlyPlayingAPI = await response.json();
return data;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment