Spotify API 错误代码 400 - 无搜索查询
Spotify API Error Code 400 - No Search Query
我正在尝试使用 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 - "no search query" 响应。谁能帮助找出为什么我的查询选项没有被正确读取?
谢谢。
已解决:请求库在选项对象中需要一个名为 qs 的查询字符串对象。将 "data" 更改为 "qs" 修复了它。
我正在尝试使用 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 - "no search query" 响应。谁能帮助找出为什么我的查询选项没有被正确读取?
谢谢。
已解决:请求库在选项对象中需要一个名为 qs 的查询字符串对象。将 "data" 更改为 "qs" 修复了它。