【问题标题】:Spotify API Error Code 400 - No Search QuerySpotify API 错误代码 400 - 无搜索查询
【发布时间】:2017-12-03 00:28:03
【问题描述】:

我正在尝试使用 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 - “无搜索查询”响应。谁能帮助找出为什么我的查询选项没有被正确读取?

谢谢。

【问题讨论】:

    标签: javascript http spotify


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-09-09
      • 2020-06-05
      • 1970-01-01
      • 2017-06-30
      • 2013-06-14
      • 2017-10-19
      • 1970-01-01
      • 2019-12-02
      相关资源
      最近更新 更多