gpt4 book ai didi

javascript - Spotify API 错误代码 400 - 无搜索查询

转载 作者:行者123 更新时间:2023-12-01 02:40:17 26 4
gpt4 key购买 nike

我正在尝试使用 Spotify API 搜索功能来接收专辑数据。这是我的要求:

request.post(authOptions, function(error, response, body) {
if (!error && response.statusCode === 200) {

// use the access token to access the Spotify Web API
var token = body.access_token;
var options = {
url: 'https://api.spotify.com/v1/search',
data: {
q: 'currents',
type: 'album',
},
headers: {
'Authorization': 'Bearer ' + token
},
json: true
};

request.get(options, function(error, response, body) {
console.log(body);
});
}
});

但是,当执行此代码时,我不断收到错误代码 400 - “无搜索查询”响应。任何人都可以帮助找出为什么我的查询选项没有被正确读取吗?

谢谢。

最佳答案

已解决:请求库需要在选项对象中包含一个名为 qs 的查询字符串对象。将“data”更改为“qs”修复了它。

关于javascript - Spotify API 错误代码 400 - 无搜索查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47614039/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com