I am trying to implement this library with my React applicaiton however, I get an error when I import the package.
Error - TypeError: Object prototype may only be an Object or null: undefined
Package - https://www.npmjs.com/package/dukascopy-node
I tried importing it both ways, using require and using import from however it gives the same output
Function
import { getHistoricRates } from "dukascopy-node";
export const getHistoricalData = async (
instrument = "btcusd",
from = new Date("2018-01-01"),
to = new Date("2019-01-01"),
timeframe = "d1"
) => {
try {
const data = await getHistoricRates({
instrument: instrument,
dates: {
from: from,
to: to,
},
timeframe: timeframe,
format: "json",
});
console.log(data);
} catch (error) {
console.log("error", error);
}
};
As the import statement looks OK, there must be something wrong with your packages. I would try to delete the node_modules folder and reinstall all packages. This is my go-to solution in such strange, unexplainable cases with imports.