0
使用API v1。在Spotify應用程序api中鏈接加載調用
不知道多頻繁我不得不做這樣的事情,但我懷疑一點點。
我想檢查用戶是否是播放列表的所有者。是否有可能沒有下面的嵌套負載鏈接?我看到那Promises can be joined,但我不認爲我可以加載currentUser
未加載owner
。任何方式來簡化這個?
var drop = models.Playlist.fromURI(...);
var success_message = document.createElement('p');
success_message.innerHTML = 'Playlist successfully dropped: ' + drop.uri;
this.appendChild(success_message);
drop.load('owner').done(function (playlist) {
playlist.owner.load('currentUser').done(function (owner) {
if (owner.currentUser) {
var allowed_message = document.createElement('p');
allowed_message.innerHTML = 'You are the owner of this playlist, let\'s get to work!';
drop_box.appendChild(allowed_message);
}
else {
var disallowed_message = document.createElement('p');
disallowed_message.innerHTML = 'You are not the owner of this playlist, choose a different one please!';
drop_box.appendChild(disallowed_message);
}
});
});
從我所看到的,看起來這個嵌套是計劃。類似。 – Thomas