【问题标题】:last.fm GET request timing out meteorlast.fm GET 请求超时流星
【发布时间】:2017-06-09 10:31:08
【问题描述】:

我目前正在尝试使用简单的 GET 请求访问 last.fm 的 API。我发现的最好的 NPM 库是 feross 的 last-fm。问题是我的请求一直超时并且我没有收到任何错误。是流星造成的吗?

我的请求网址是: https://ws.audioscrobbler.com:3000/2.0/?method=artist.getInfo&artist=cher&autocorrect=1&api_key=MY_API_KEY&format=json

这里是代码。

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();
    }

【问题讨论】:

    标签: node.js reactjs meteor last.fm


    【解决方案1】:

    我已经删除了端口 :3000 并且它可以正常工作。使用以下网址:

    https://ws.audioscrobbler.com/2.0/?method=artist.getInfo&artist=cher&autocorrect=1&api_key=MY_API_KEY&format=json

    【讨论】:

    • 啊,谢谢!但是你知道为什么我的本地主机端口会出现在 api 调用中吗?
    • 不确定。在feross的last-fm库中,index.js文件有一个名为const urlBase的变量,确保正确的url设置为https://ws.audioscrobbler.com/2.0/
    • 明天我会部署它,看看是否能解决问题,感谢您帮助我找到它。
    猜你喜欢
    • 1970-01-01
    • 2013-09-14
    • 2020-06-17
    • 1970-01-01
    • 2019-03-04
    • 2020-12-13
    • 1970-01-01
    • 2011-02-26
    • 1970-01-01
    相关资源
    最近更新 更多