当我使用npm request调用这个api时,我得到一个空数组。我已经加载了请求并在页面顶部定义了内容的值(这里没有显示)。我还在这里更改了api密钥。这三件事都不是问题(请求、内容或api密钥)。
当我使用Chrome://inspect
运行调试器时,它在err/response中显示一个失败,内容为:
错误=空,响应= IncomingMessage {_readableState: ReadableState,可读: false,域:空,_events:{…},_eventsCount: 4,…},body =‘
代码如下:
function concertThis(){
var queryUrl = "https://rest.bandsintown.com/artists/" + content +
"/events?app_id=api_key"
console.log(queryUrl);
request(queryUrl, function(err, response, body){
if(!err && response.statusCode === 200){
debugger;
console.log("-------");
console.log(JSON.parse(body));
}
})
}
这是我的终端中的结果:
$ node liri.js concert-this mumford and sons
https://rest.bandsintown.com/artists/mumford+and+sons/events?
app_id=api_key
-------
[]
谢谢你的帮忙!
发布于 2018-12-18 04:34:31
我使用bandsintown api in-documentation execute尝试了一下,它返回了一个空数组。会不会是Mumford and Sons没有任何即将到来的活动?你试过别的乐队吗?
Shawn Mendes的Here is an example,他有事件,并且在响应中有信息。
https://stackoverflow.com/questions/53822501
复制相似问题