adam-cowley / skyscanner

Skyscanner SDK for Node
MIT License
1 stars 1 forks source link

Hi i get issue #1

Open maxto024 opened 7 years ago

maxto024 commented 7 years ago

Hi
I try to run your sdk code

first i did npm install
then Node example.js

i get this error screenshot from 2017-02-12 20-38-08

adam-cowley commented 7 years ago

Hey,

Thanks for trying this package out. The library was written in ES6 so you'll need to run it with babel-node for it to recognise the import statements. (npm i -G babel-cli then babel-node example.js. Alternatively you could change the first line of the example file.

const Skyscanner = require('./lib/Skyscanner');

const service = new Skyscanner('YOUR_API_KEY');
// ...etc

and then change the arrow functions to vanilla javascript.

service.autosuggest('Napoli')
    .then(function(suggestions) { // rather than .then(suggestions => {...}
        return suggestions[0].PlaceId;
    })

Looking around though, there are some better packages that you could use. I've not touched this in a long time.