JMPerez / spotify-web-api-js

A client-side JS wrapper for the Spotify Web API

Home Page:https://jmperezperez.com/spotify-web-api-js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

createPlaylist 401 error

mlam28 opened this issue · comments

Hi,

When trying to create a playlist for a user, i keep getting a 401 error, 'no token provided', even though I have already set the access token using .setAccessToken.

I do not know what is wrong could you please assist? Here is my code;
Screen Shot 2019-09-30 at 12 59 12 AM

Ah, this was close. I just tested it locally and ran into the same problems with your code.
I was able to make it work by removing the JSON.stringify call. My request now looks like this:
spotifyApi.createPlaylist(spotifyId, {name: "New Playlist"}).then(resp => console.log(resp));

Let me know if that doesn't work for you!

Closing this issue. The createPlaylist function expects a JSON object as options, so removing JSON.stringify() should make it work. Thanks @kevinguebert for supporting.