terhuerne / setlistfm-js Goto Github PK
View Code? Open in Web Editor NEWThis is an easy to use, promise based API wrapper for the most recent version of the setlist.fm Web API. Made with love and JavaScript.
License: MIT License
This is an easy to use, promise based API wrapper for the most recent version of the setlist.fm Web API. Made with love and JavaScript.
License: MIT License
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.
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
Issue created to fix the node-fetch vulnerability: see this advisory for more information.
Remediation: simply upgrade node-fetch to version 2.6.1 or later.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.