b3gund4L icon

Api Spotify

b3gund4L | PRO | 04/11/17 08:55:09 PM UTC | 0 ⭐ | 41696 👁️ | Never ⏰ | []
JSON |

1.17 KB

|

None

|

0 👍

/

0 👎

curl -X GET "https://api.spotify.com/v1/users/***userId***/playlists" -H "Accept: application/json" -H "Authorization: Bearer ***ACCESSTOKEN***"
    
app.get('/user-playlists', function(req, res){
 
    var options = {
        url: 'https://api.spotify.com/v1/me',
        headers: {
            'Authorization': 'Bearer ' + access_token
        },
        json: true
    };
 
    rp(options).then(function(body) {
        userEmail = body.email;
        userId = body.id;
 
        var optionsTwo = {
            url: 'https://api.spotify.com/v1/users/' + userId + '/playlists',
            headers: {
                'Authorization': 'Bearer ' + access_token
            },
            json: true
        };
 
        return rp(optionsTwo).then(function (body) {
            playlists = body.items;
            console.log(playlists)
            res.json(playlists);
        });
    }).catch(function (err) {
        console.log(err)
    })
});
    
$.ajax({
   type: 'GET',
   url: 'http://localhost:3000/user-playlists',
   contentType: 'application/json',
   success: function(data) {
     console.log(data); //this is only returning four playlist items
   }
 });

Comments