Spotify 应用程序 API 调用无法返回

发布于 2025-01-08 05:21:31 字数 370 浏览 3 评论 0 原文

我正在构建一个应用程序,它在首次加载时请求多个专辑和播放列表的数据。

对于其中的每一个,我都调用

models.Album.fromURI(uri, function(album){});

或 。

models.Playlist.fromURI(uri, function(playlist){});

大多数情况下,这些工作正常,我可以从回调函数中从专辑或播放列表中获取信息,但是,偶尔(5%的时间)回调函数永远不会被调用我的应用程序显示的数据集不完整。

我想知道是否有其他人遇到过类似的问题或对可能导致该问题的原因有任何见解(API 错误、请求速率限制等)

I'm building an app which requests data for several albums and playlists when it first loads.

For each of these I am calling either

models.Album.fromURI(uri, function(album){});

or

models.Playlist.fromURI(uri, function(playlist){});

For the majority of the time these work fine and I can get info from the album or playlist from within the callback function, however, occasionally (5% of the time) the callback function is never called and I'm left with an incomplete data set for my app to display.

I'm wondering if anyone else has encountered similar problems or has any insight into what might be causing it (API bugs, request rate limiting, etc)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花桑 2025-01-15 05:21:32

不幸的是,Spotify Apps API 0.X 缺少错误回调函数,当调用 models.Album.fromURImodels.Playlist.fromURI 时出现问题时,可以调用该函数。

通过使用 承诺

models.Track.fromURI('spotify:track:6a41rCqZhb2W6rpMolDR08').load('name')
    .done(function(track) { console.log(track.name); })
    .fail(function(track, error) { console.log(error.message); });

Unfortunately, the Spotify Apps API 0.X lacked an error callback function that could be called when something went wrong when calling models.Album.fromURI or models.Playlist.fromURI.

This has been greatly improved in the Spotify Apps API 1.x through the use of Promises:

models.Track.fromURI('spotify:track:6a41rCqZhb2W6rpMolDR08').load('name')
    .done(function(track) { console.log(track.name); })
    .fail(function(track, error) { console.log(error.message); });
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文