thelinmichael / spotify-web-api-node

A Node.js wrapper for Spotify's Web API.
http://thelinmichael.github.io/spotify-web-api-node/
MIT License
3.1k stars 499 forks source link

TypeError: Cannot read properties of undefined (reading 'join') #462

Open ADEV-00 opened 2 years ago

ADEV-00 commented 2 years ago

I am having problem with spotifyApi.areFollowingPlaylist. I am testing the example you provided

  spotifyApi.areFollowingPlaylist('5ieJqeLJjjI8iJWaxeBLuK', [
          'thelinmichael',
          'ella',
        ])
        .then(
          function (data: any) {
            data.body.forEach(function (isFollowing: any) {
              console.log('User is following: ' + isFollowing)
            })
          },
          function (err: any) {
            console.log('Something went wrong!', err)
          }
        ) 

But I am getting the error: TypeError: Cannot read properties of undefined (reading 'join')

ADEV-00 commented 2 years ago

For some reason, the function needed a parameter before the playlist id. I manage to fix my problem like this:

spotifyApi.areFollowingPlaylist('spotify', '5ieJqeLJjjI8iJWaxeBLuK', [
          'thelinmichael',
          'ella',
        ])
        .then(
          function (data: any) {
            data.body.forEach(function (isFollowing: any) {
              console.log('User is following: ' + isFollowing)
            })
          },
          function (err: any) {
            console.log('Something went wrong!', err)
          }
        ) 

Can someone explain to me what this first parameter is?

kevinguebert commented 2 years ago

Looks like the README may need to be updated as the issue may be coming from the followers being undefined

From: https://github.com/thelinmichael/spotify-web-api-node/blob/be15f1c742b35134ce5bd35521d8bf1ab1ba67cf/src/spotify-web-api.js#L1342-L1348