Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with getUserPlaylists parameters #226

Closed
ivaansm opened this issue Jul 8, 2018 · 8 comments
Closed

Problem with getUserPlaylists parameters #226

ivaansm opened this issue Jul 8, 2018 · 8 comments

Comments

@ivaansm
Copy link

ivaansm commented Jul 8, 2018

Hello, I am using this wrapper for NodeJS. I have a question about the getUserPlaylists method and its parameters. I want to specify the limit and the offset and I don't know how to specify them because it is not clear in the docs.
I did it like this but it doesn't work.
spotifyApi.getUserPlaylists({limit: 27, offset: 7}) .then(function(data) {

@JMPerez
Copy link
Collaborator

JMPerez commented Jul 9, 2018

Use getUserPlaylists to fetch a certain user's playlists. You need to pass the userId as the first parameter. See https://github.com/thelinmichael/spotify-web-api-node/blob/master/src/spotify-web-api.js#L445-L455 for more information.

There is another endpoint to fetch the current user's playlists that doesn't need an explicit userId, but it's not implemented in this library yet.

@ivaansm
Copy link
Author

ivaansm commented Jul 9, 2018

That's not what I was asking, but thanks. getUserPlaylists does not need the userId and in that case, it will fetch the playlist of the user that is logged in. I want to know info about the parameters of getUserPlaylists and how to specify them. I did it like I specified it in the question but it doesn't work. In the link that you wrote for more information it is stated that it can have an object with options as parameters but I don't know how to write it. Can you help me with that? Because, in my opinion it is not well explained in the docs.

@JMPerez
Copy link
Collaborator

JMPerez commented Jul 10, 2018

True, my fault. I should have read the documentation of the function better.
The options that you can pass are the ones that the endpoint supports, which are limit and offset.

The problem is that there is a bug in the implementation. When the userId is not provided it should set options to the first parameter of the function, which it doesn't do. A workaround for now is to pass null as the userId:

spotifyApi.getUserPlaylists(null, {limit: 27, offset: 7}).then(function(data) {

Let me know if that solves it and I'll file a ticket to fix this.

@ivaansm
Copy link
Author

ivaansm commented Jul 11, 2018

Yes, that solves it! Thank you very much! Muchas gracias (también soy español) :)

@JMPerez
Copy link
Collaborator

JMPerez commented Jul 11, 2018

¡Me alegro de que haya funcionado!

@piyushsingh0992
Copy link

spotifyApi
.getUserPlaylists() is returning an empty item list how to solve that ?

@hirensavani-99
Copy link

hirensavani-99 commented Feb 16, 2021

@piyushsingh0992 i am getting same problem if you have solved the problem can you help me?

@jsears
Copy link

jsears commented Mar 26, 2021

This is not working for me. Consistently returns:
WebapiRegularError: An error occurred while communicating with Spotify's Web API.

Has the methodology for this changed?

ETA: nm, distregard, error was limit being set was not valid. But I couldn't see the actual error, would be nice. Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants