Announcements

Help Wizard

Step 1

NEXT STEP

FAQs

Please see below the most popular frequently asked questions.

Loading article...

Loading faqs...

VIEW ALL

Ongoing Issues

Please see below the current ongoing issues which are under investigation.

Loading issue...

Loading ongoing issues...

VIEW ALL

Problem with React/authorization

Problem with React/authorization

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.

const response = await fetch(`https://api.spotify.com/v1/users/${user}/playlists`, reqOptions)

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
2 Replies

You'll need to add other accounts (up to 25) to the dashboard of your app when it is in development mode. After it is ready to publish to the public, you can request a quota extension.

XimzendSpotify Star
Help others find this answer and click "Accept as Solution".
If you appreciate my answer, maybe give me a Like.
Note: I'm not a Spotify employee.

I am also facing the same issue. Were you able to resolve this issue?

 

Suggested posts

Type a product name