无法更改 Spotify API 的默认限制(顶级艺术家) - React Native



我已经尝试了一切来改变这一点。。。不知道出了什么问题,不管怎样,它仍然只是把20位艺术家拉回来。

const sp = await this.getValidSPObj();
const { id: userId } = await sp.getMe();
const { items: topArtists } = await sp.getMyTopArtists(userId, {limit: 10, offset: 20});
this.props.setData("TopArtists", topArtists);

API注释。。。

/**
* Get the current user’s top artists based on calculated affinity.
* See [Get a User’s Top Artists](https://developer.spotify.com/web-api/get-users-top-artists-and-tracks/) on
* the Spotify Developer site for more information about the endpoint.
*
* @param {Object} options A JSON object with options that can be passed
* @param {function(Object,Object)} callback An optional callback that receives 2 parameters. The first
* one is the error object (null if no error), and the second is the value if the request succeeded.
* @return {Object} Null if a callback is provided, a `Promise` object otherwise
*/
getMyTopArtists(
options?: Object,
callback?: ResultsCallback<SpotifyApi.UsersTopArtistsResponse>
): Promise<SpotifyApi.UsersTopArtistsResponse>;

根据函数signatureuserID没有standalone参数,您将userID作为first参数传递,实际上first参数是options对象!

文档还提到一些CCD_ 8不需要CCD_https://github.com/JMPerez/spotify-web-api-js#getting-用户信息

有些函数不需要接收用户的id作为参数,而是使用访问令牌中的用户信息:<code_example>

p.s.:我相信基于您的access_tokenscope,它可以计算出用户。

最新更新