Closed neilime closed 4 years ago
I had the same issue! Since I don't use Typescript I was able to just use the first parameter as options, but my IDE is not happy of course. And for me it was very confusing figuring out why it didn't work initially.
I faced the same issue. A workaround is adding // @ts-ignore
before the function call.
I had the same issue, and I dug a bit in the source. Here's what I found if it could help:
getUserPlaylists(undefined, { limit: 20 })
with userId as undefined, the options
get replace with userId
and options
are forwarded to callback https://github.com/JMPerez/spotify-web-api-js/blob/b0c0143c961c5ebed699a450471ad47820e64ed2/src/spotify-web-api.js#L676-L690_checkParamsAndPerformRequest
is called with _checkParamsAndPerformRequest(requestData, undefined, { limit: 20 })
, and it turns out the options
and the callback
are removed from the request
https://github.com/JMPerez/spotify-web-api-js/blob/b0c0143c961c5ebed699a450471ad47820e64ed2/src/spotify-web-api.js#L143-L162I got around this issue by requesting the userId
and calling getUserPlaylists(userId, { limit: 20 })
instead.
I need to retrieve the first 50 playlists of current user.
Typescript definition of function getUserPlaylists :
getUserPlaylists(userId?: string, options?: Object,...
suggest to do :getUserPlaylists(undefined, {limit: 50});
I does not work...
Actually the function
getUserPlaylists
does not work as expected according to the doc and typescript typing.If the userId is not a string (undefined or anything else), the first argument become the options.
But in typescript you cannot pass an object as the first argument because it must be a string or undefined.