Problem with React/authorization
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi guys, im new to programming, but i really started to enjoy it.
I want to make a web app that after pressing a button, creates playlist with last 10 songs you listened to.
I ALMOST got it working, however I found one big obstacle.
const create_playlist = async (e) => {
e.preventDefault()
const reqOptions =
{
method: "POST",
headers: {
"Authorization": "Bearer " + token,
},
body: JSON.stringify({
name: "SpotEx",
})
}
const response = await fetch(`https://api.spotify.com/v1/users/HERE_IS_MY_PROFILE_ID/playlists`, reqOptions)
const data = await response.json()
I can use code like that, it creattes playlist and works. However if any other account would login, thus different Profile ID, it will stop working.
I can use code like that, it creattes playlist and works. However if any other account would login, thus different Profile ID, it will stop working.
const response = await fetch(`https://api.spotify.com/v1/users/${user}/playlists`, reqOptions)
Provides me with CORS errors that I cannot resolve
Provides me with CORS errors that I cannot resolve
Access to XMLHttpRequest at 'https://api.spotify.com/v1/users/[object%20Object]/playlists' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page