0
我正在尝试使用简单的GET请求访问last.fm的API。我发现的最好的NPM库是由feross最后一个。问题是我的请求保持超时,我没有得到任何错误。流星造成这种情况吗?last.fm GET请求超时流星
这里是代码。
import LastFM from 'last-fm';
const lastfm = new LastFM("MY_API_KEY", {userAgent: "buildsmoothie"})
export const ArtistCheck =() => {
lastfm.artistInfo({ name: "cher" }, (err, data) => {
if (err) console.log(err)
else console.log(data)
})
}
然后我把它在这里的另一个组件:
artistGateCheck(e){
e.preventDefault();
ArtistCheck();
}
谢谢!但是你知道为什么我的本地主机端口显示在api调用中吗? – John
不确定。在feross的last-fm库中,index.js文件有一个名为'const urlBase'的变量,确保将正确的url设置为https:// ws.audioscrobbler.com/2.0 /' –
它明天,看看是否停止了这个问题,谢谢你帮我找到它。 – John