reactjs - 无法更改 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>;
解决方案
根据函数signature
没有standalone
参数userID
,您userID
作为first
参数传递,实际上first
参数是options
对象!
文档还提到有些functions
不需要userID
:
https ://github.com/JMPerez/spotify-web-api-js#getting-users-information
有些函数不需要接收用户的 id 作为参数,会使用访问令牌中的用户信息:<code_example>
ps:我相信根据你的access_token
,scope
它会计算出用户。
推荐阅读
- java - Azure Functions 和临时文件存储
- python - 在 django 项目启动时定义变量
- spring - Spring Jackson ObjectMapper 在单元测试通过时无法进行 JSON 反序列化
- node.js - 使用 Sharp 获取调整后图像的精确尺寸
- javascript - Javascript:编写函数和条件检查的干净和优化方式的最佳实践
- cypress - 第二次启动cypress测试,url登陆错误页面
- animation - 使用 SVG 为书法制作动画
- git - Gitlab CI 不适用于 Gitlab Registry 中的私有图像
- node.js - TypeError:无法设置 null - 节点和 Mongoose 的属性“brief_title”
- c++ - 需要 GLIBC 2.7 版本。使用更高版本的 GLIBC 编译 C++ 代码,同时支持更早的 glibc