I'm trying to make a ReactJS app that utilizes the Spotify API, but I keep receiving this error:
const client_id = ''; //hidden
const redirect_uri = 'http://localhost:3000/'
let accessToken;
const Spotify = {
async getAccessToken(){
if (accessToken){
return accessToken;
}
try{
let response = await fetch(`https://cors-anywhere.herokuapp.com/https://accounts.spotify.com/authorize?client_id=${client_id}&response_type=token&redirect_uri=${redirect_uri}`);
if (response.ok){
let jsonResponse = await response.json();
console.log(jsonResponse);
}
}catch (e){
console.log(e);
}
}
}
export default Spotify;
I've read around and I hear this is a server-side issue? If so, is there a work-around it? By the way I am using this https://cors-anywhere.herokuapp.com/
to prevent the CORS error.
Thanks for any help. I'll keep working on it. If I find anything, I'll post up the solution right away!