Reactjs 错误400错误请求Spotify API Post请求
我正在开发一个web应用程序,用户可以搜索音乐,创建一个新的播放列表,然后将其保存到他们的Spotify帐户。我现在一直在用户Spotify上创建一个新的播放列表Reactjs 错误400错误请求Spotify API Post请求,reactjs,api,spotify,Reactjs,Api,Spotify,我正在开发一个web应用程序,用户可以搜索音乐,创建一个新的播放列表,然后将其保存到他们的Spotify帐户。我现在一直在用户Spotify上创建一个新的播放列表 ` //userUd, playlistName, currentUserAccessToken are all defined fetch(`https://api.spotify.com/v1/users/${userId}/playlists`, { headers: {
` //userUd, playlistName, currentUserAccessToken are all defined
fetch(`https://api.spotify.com/v1/users/${userId}/playlists`, {
headers: {
'Authorization': 'Bearer ' + currentUserAccessToken
},
contentType: 'application/json',
method: 'POST',
body: {
"name": `${playlistName}`,
"description": `You made this playlist with Jammming, a ReactJS web application built by Max Page`
}
}).then(playlist => {
console.log(playlist);
return playlist.json();
}).catch(err => {
console.log(err);
})`
这里的目标是获得新的playlid,有人知道我为什么会收到400个错误请求吗?我做了GET请求,授权用户创建公共播放列表的范围,在不同的代码块中工作,如下所示:
`let scopes = 'playlist-modify-public';
window.location.replace(`https://accounts.spotify.com/authorize?client_id=${clientID}&scope=${scopes}&redirect_uri=${redirectURI}&response_type=token`);`
提前谢谢 收紧你的身体。这就是为我修正相同错误的原因
fetch(`https://api.spotify.com/v1/users/${userId}/playlists`, {
headers: {
'Authorization': 'Bearer ' + currentUserAccessToken
},
contentType: 'application/json',
method: 'POST',
body: JSON.stringify({
"name": `${playlistName}`,
"description": `You made this playlist with Jammming, a ReactJS web application built by Max Page`
})
}).then(playlist => {
console.log(playlist);
return playlist.json();
}).catch(err => {
console.log(err);
})`