Plan
Premium
Country
Argentina
Device
(iPhone 8, Samsung Galaxy 9, Macbook Pro late 2016)
Operating System
Windows 10
My Question or Issue
I'm trying to make a GET request to the Spotify Web API for a track using simple JavaScript (I don't know curl), but it's giving me a 404 error
My code:
//async function to get the token
const getToken = async() => {
method: 'POST',
body: 'grant_type=client_credentials',
headers: {
'Authorization': 'Basic ' + Buffer.from(clientID + ':' + clientSecret).toString('base64'),
'Content-Type': 'application/x-www-form-urlencoded'
}
})
const data = await result.json();
const realToken = data.access_token;
return realToken;
}
getToken().then((token) => {
//async function to get songs
const getTracks = async(whatever) => {
method: 'GET',
headers: {
'Authorization': 'Bearer ' + whatever,
'Content-Type': 'application/json'
}
});
const data = await result.json();
return data;
}
getTracks(token);
});