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

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

Open ADEV-00 opened this issue 3 years ago • 2 comments

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 avatar Sep 01 '22 10:09 ADEV-00

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?

ADEV-00 avatar Sep 02 '22 16:09 ADEV-00

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

kevinguebert avatar Sep 08 '22 14:09 kevinguebert