Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement