【问题标题】:Can't change default limit on Spotify API (Top Artists) - React Native无法更改 Spotify API(顶级艺术家)的默认限制 - React Native
【发布时间】:2020-09-04 15:10:28
【问题描述】:

我已尽一切努力改变这一点...不知道出了什么问题,无论如何它仍然只是将 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>;

【问题讨论】:

    标签: reactjs api native spotify


    【解决方案1】:

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

    文档还提到一些functions 不需要userID: https://github.com/JMPerez/spotify-web-api-js#getting-users-information

    有些函数不需要接收用户的id作为参数,会使用access token中的用户信息:

    p.s.:我相信根据您的 access_token 和 scope 它可以找出用户。

    【讨论】:

      猜你喜欢
      • 2021-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-07
      • 2017-04-27
      • 1970-01-01
      相关资源
      最近更新 更多