fhqvst / avanza

A JavaScript client for the unofficial Avanza API
MIT License
229 stars 59 forks source link

Can't get demo code to work #45

Closed mountaindude closed 4 years ago

mountaindude commented 4 years ago

I am probably missing something totally obvious... but I just can't get the simple demo code to run in Node v12.13.1

➜  avanza2 node positions.js
/Users/goran/code/avanza2/positions.js:1
import Avanza from 'avanza'
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Module._compile (internal/modules/cjs/loader.js:895:18)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
    at internal/main/run_main_module.js:17:11
➜  avanza2

Are there any requirements not listed in the readme file, maybe..? Thx, Göran

fhqvst commented 4 years ago

The example assumes that you're using a transpiler or compiler. Just do const Avanza = require('avanza') instead and then proceed as usual.