spotify-web-api-node icon indicating copy to clipboard operation
spotify-web-api-node copied to clipboard

getPlaylist returns invalid playlist ID no matter input

Open ZoeyOneOhOne opened this issue 6 years ago • 4 comments

get

The first function returns "uncaught exception: Object" but the second one returns: "{\n "error" : {\n "status" : 404,\n "message" : "Invalid playlist Id"\n }\n}" regardless of which playlist ID I try to use. Other spotify api calls I have in my app work just fine. Only this call is acting weird.

ZoeyOneOhOne avatar Mar 20 '20 05:03 ZoeyOneOhOne

It seems to be working over here, used the same playlist as above.

fabiogaliano avatar Mar 26 '20 17:03 fabiogaliano

That's really interesting... I will try to figure something out when I get off work and I'll let you know. Thank you for getting back to me.

ZoeyOneOhOne avatar Mar 26 '20 17:03 ZoeyOneOhOne

Ya I still can't get this particular call to work. Any ideas?

ZoeyOneOhOne avatar Mar 27 '20 02:03 ZoeyOneOhOne

At first everything seems fine in your code, I'm just not sure how you are calling the function. Either way here's a snippet that works.

var SpotifyWebApi = require("spotify-web-api-node");

let spotifyApi = new SpotifyWebApi();
spotifyApi.setAccessToken(process.env.ACCESS_TOKEN);

async function getSlamsPlaylist(playlistID) {
  let playlistObj = (await spotifyApi.getPlaylist(playlistID)).body;
  //do something with playlistObj
  console.log(playlistObj);
}

getSlamsPlaylist("7CoPUH1fJFKzcc7NAIv9XU");


// without async 

function getSlamsPlaylistV2(playlistID) {
  spotifyApi
    .getPlaylist(playlistID)
    .then(res => console.log(res.body))
    .catch(err => console.log(err));
}

getSlamsPlaylistV2("7CoPUH1fJFKzcc7NAIv9XU");

fabiogaliano avatar Mar 27 '20 07:03 fabiogaliano