node.js - Using a special API call -


i wanted checkout goeuro-api, get:

goeuroapi not constructor

you can give try here:

https://runkit.com/npm/goeuro-api

my code:

var goeuroapi = require("goeuro-api");  const goeuroclient = new goeuroapi();  var params = {     "searchoptions": {         "departureposition": { "id": 376217 },         "arrivalposition": { "id": 377001 },         "travelmodes": ["flight", "train", "bus"],         "departuredate": "2017-04-08",         "returndate": null,         "passengers": [{ "age": 12 }],         "userinfo": {             "identifier": "0.dj87mh4f039",             "domain": ".com", "locale": "en", "currency": "eur"         },         "abtestparameters": []     } };  // init search , flights, trains , buses. goeuroclient.search(params)   .then((response) => {       goeuroclient.flights()         .then(flights => console.log(flights));        goeuroclient.trains()         .then(trains => console.log(trains));        goeuroclient.buses()         .then(buses => console.log(buses));   })   .catch((error) => console.log(error));  // buses search_id goeuroclient   .buses({ search_id: id })   .then(buses => console.log(buses))   .catch(error => console.log(error)); 

what wrong here, should instead ?

thanks help.

while importing goeuro-api

var goeuroapi = require("goeuro-api"); 

it exposes object { default: [function: goeuroapi] }

instead use constructor function

do

var goeuroapi = require("goeuro-api").default; // exposes function                                                 // [function: goeuroapi]  const goeuroclient = new goeuroapi(); 

Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -