Created
February 25, 2022 16:17
-
-
Save Yidaotus/d1f5da05eca4ec7ad87e4284a8daae9c to your computer and use it in GitHub Desktop.
Fetch Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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