Open KonkenBonken opened 4 years ago
Issue a fetch request.
For example:
const myHeaders = new Headers({
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer BQBSzHFnjIuzHSAGKWlOc9999999999mVD1GfHM6v7amACnUw1PTJg8njubEzMWEKNiPe06H_gc5eu3wWEynsF1h4q2UY6YGRFGSXagdvpxhDV_kBA6qTK9999999999u9ulPsbkTW5mgRTy7T3dgBEVNjaMZC1KQPLT1Txbc20999tbXe38OW73YCNe4aT4uO3aMg'
});
const myRequest = new Request('https://api.spotify.com/v1/me/player/currently-playing', {
method: 'GET',
headers: myHeaders,
});
fetch(myRequest)
.then((response) => response.body())
.then((receivedBody) => {
// your code here
});
On this Spotify gives a code to get the User's Currently Playing Track using CURL. Like this:
curl -X "GET" "https://api.spotify.com/v1/me/player/currently-playing" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer BQBSzHFnjIuzHSAGKWlOc9999999999mVD1GfHM6v7amACnUw1PTJg8njubEzMWEKNiPe06H_gc5eu3wWEynsF1h4q2UY6YGRFGSXagdvpxhDV_kBA6qTK9999999999u9ulPsbkTW5mgRTy7T3dgBEVNjaMZC1KQPLT1Txbc20999tbXe38OW73YCNe4aT4uO3aMg"
But how do I get the User's Currently Playing Track using Javascript?
OBS. I've changed the token in this post