Friday, 17 April 2020

Why is this nested request not running in Node.js with Spotify API?

I am using the authorization code flow to have a user log in and allow me to access and create playlists on their account. I have followed along with the docs and I am now trying to read the users playlists but my nested request is not running. Here is my code:// use the access token to access the Spotify Web API request.get(options, function(error, response, body) { console.log(body.id); if(response){ request.get({url: 'https://api.spotify.com/v1/users/'+body.id+'/playlists', headers:{ 'Authorization': 'Bearer ' + access_token }, function(error, response, body){ //var playlists = JSON.parse(response.body); console.log("this code runs"); } }) } }); As of now I retrieve the the users id, which does log to the console, and then pass the user's id to the next endpoint but the second request is not running. I am using this endpoint.

Submitted April 17, 2020 at 05:33PM by TheSlothJesus

No comments:

Post a Comment