【发布时间】:2020-04-06 04:53:40
【问题描述】:
我响应 POST https://api.spotify.com/v1/users/{user_id}/playlists 得到的播放列表对象应该包含一个播放列表“id”属性。
https://developer.spotify.com/documentation/web-api/reference/playlists/create-playlist/
但是,我得到的响应对象有一个“id”属性,它给出了用户 ID,而不是播放列表 ID。
我可以创建播放列表,但在不知道播放列表 ID 的情况下,我无法向其中添加曲目。
我的代码:
return fetch(`https://api.spotify.com/v1/users/${userId}/playlists`,
{
headers: {Authorization: `Bearer ${accessToken}`, 'Content-Type': 'application/json'},
method: 'POST',
body: JSON.stringify({name:playlistName})
}).then(response => response.json()
).then(jsonReponse => {
const playlistId = jsonResponse.id;
console.log(playlistId); // not getting playlist id!
console.log(jsonResponse);
console.log(trackURIs);
console.log(accessToken);
});
范围默认是公开的。
创建播放列表后是否有其他人无法访问播放列表 ID?
【问题讨论】:
-
语法错误/错别字(如下所述) - 这很奇怪。到该 URL 的 POST 应该从 Spotify 的 API 返回播放列表对象。你能发布完整的回复吗?
标签: javascript spotify