0

I'm currently trying to access last.fm's API using a simple GET request. The best NPM library I found was last-fm by feross. The problem is that my request keeps timing out and I don't get any errors. Is meteor causing this?

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

Here is the code.

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

And then I call it in another component here:

artistGateCheck(e){
    e.preventDefault();
      ArtistCheck();
    }
John
  • 1,075
  • 1
  • 7
  • 13

1 Answers1

2

I've removed the port :3000 and it works as it should. Used the follow url:

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

John
  • 1,075
  • 1
  • 7
  • 13
  • Ah thanks! But do you know why does my local host port show up in the api call? – John Jun 09 '17 at 01:37
  • Not sure. In the library last-fm by feross, the index.js file have a variable called `const urlBase`, make sure the right url is set as `https://ws.audioscrobbler.com/2.0/` – Igor Ribeiro Jun 09 '17 at 02:35
  • I'll deploy it tomorrow and see if that stops the problem, thanks for helping me locate it. – John Jun 09 '17 at 03:52