icastillejogomez / degiro-api

Unofficial DeGiro stock broker API. See your portfolio and set up orders in the market like wall street
MIT License
195 stars 29 forks source link

Problems using import #46

Closed luixal closed 1 year ago

luixal commented 1 year ago

Hi,

I just got started with DeGiro and this package... and I'm having some problems when using import:

If I try this code:

import DeGiro from "degiro-api";

const username = 'myUsername';
const password = 'myPassword';

const degiro = new DeGiro({ username, password });

I just got the following error:

TypeError: DeGiro is not a constructor

If I opt to use the create function, like this:

const degiro = DeGiro.create({username, password});

I got this error:

TypeError: DeGiro.create is not a function

I've tried the same code using Node 16.x and 18.x, any idea of what can be the problem?

Thanks for your work!

danielvandenberg95 commented 1 year ago

Hi luixal,

In your other question I see you got this to work with require. As such, I'm assuming this is a problem with your build setup, not with this project. To confirm the issue is not in this project, could you try importing any other project?

luixal commented 1 year ago

Hi,

I don't have this issue in other projects. Just for testing, I've added lodash to the project where I'm trying to use this package and I can import an use lodash without any problems.

Don't think it's a problem with my setup. Can you point me in a direction to find out what's happening?

Thanks!

j-a-m-l commented 1 year ago

@luixal try:

import degiroApi from 'degiro-api'
const DeGiro = (degiroApi as any).default
yarcheek commented 1 year ago

@luixal or try this

import degiroApi from 'degiro-api';
const DeGiro = (degiroApi).default;
luixal commented 1 year ago

Thanks @j-a-m-l and @yarcheek , that did work.

No idea why it is needed, but that should totally appear in the readme's example.

icastillejogomez commented 1 year ago

Close this from now. This repository is open to accept pull requests if you would to achieve that natively