Code Monkey home page Code Monkey logo

setlistfm-js's Issues

Unable to use from Typescript code

Hey,

I'm trying to use this .js npm package from within a .ts, but there some way that the exports are set up that it's really not liking.

The default setup of this library in a regular node.js file run from the command line:

const sfm = require("setlistfm-js");

console.log(sfm.prototype);
var client = new sfm({
    key: process.env.SETLIST_FM_API_KEY,
    format: "json"
});
console.log(client);

That first console.log(sim) prints [Function: SetlistFmApi]. The second one, console.log(client) prints:

SetlistFmApi {
  key: false,
  format: 'application/json',
  language: 'en',
  getArtist: [Function (anonymous)],
  getArtistSetlists: [Function (anonymous)],
  getCity: [Function (anonymous)],
  searchArtists: [Function (anonymous)],
  searchCities: [Function (anonymous)],
  searchCountries: [Function (anonymous)],
  searchSetlists: [Function (anonymous)],
  searchVenues: [Function (anonymous)],
  getSetlistByVersion: [Function (anonymous)],
  getSetlist: [Function (anonymous)],
  getUser: [Function (anonymous)],
  getUserAttended: [Function (anonymous)],
  getUserEdited: [Function (anonymous)],
  getVenue: [Function (anonymous)],
  getVenueSetlists: [Function (anonymous)]
}

Perfect! Everything looks good there. Now here's the same example from within typescript (note the slightly different import syntax).

import sfm = require("setlistfm-js");

console.log(sfm);
const client = sfm({
    key : process.env.SETLIST_FM_API_KEY,
    format : "json",
    language : "en",
});
console.log(client);

Here, the first log output is identical to the .js one, so I know the same correct thing is getting pulled in and it's actually reading the js source (since it prints out SetlistFmApi). The second one is undefined though. So something to do with how javascript handles its default exports compared to typescript gets the wires crossed somewhere in there.

I've used js libraries with typescript before, so I know it can be done. I just don't know enough about the package ecosystem of both to know what's messed up here. Any thoughts? Happy to put up a PR if you can just point me in the direction of a cross-compatible fix.

Error when creating the setup

When copying the instructions to setup a setlist client, i receive the following error:
ReferenceError: Setlistfm is not defined. This also occurs when I try in the npm playground. Any guidance would be greatly appreciated @terhuerne

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.