zachfejes / js-horizons

JavaScript client wrapper for the JPL Horizons Database
MIT License
6 stars 3 forks source link

Horizons is not a constructor #12

Open letUser opened 4 years ago

letUser commented 4 years ago

Hello!

I`m using your library to build 3D Solar System Map and really appreciate you for given possibilities to interact with HORIZONS. But unfortunatelly, when I try to initialize new Horizons it sends me error you can see below.

Can you please help me to understand what I do wrong?

Thanks!

Снимок

Code is simple:

import * as THREE from "three";
import { TrackballControls } from "three/examples/jsm/controls/TrackballControls.js";
import { Horizons } from "@zachfejes/js-horizons";

export default {
  name: "Map",
  props: {},
  data() {
    return {
     ...not important info...
    };
  },
  methods: {
    init: function() {
      const horizons = new Horizons();
      horizons.initialize(() => {
        horizons.search("Jupiter", (error, response) => {
          console.log(response);
          horizons.close();
        });
      });
letUser commented 4 years ago

Installed all dependencies and replace import...from by var jsHorizons = require("@zachfejes/js-horizons");

And now receive next error. What it can even be?

Снимок

letUser commented 4 years ago

Also you can write import like this

import Horizons from "@zachfejes/js-horizons";

zachfejes commented 4 years ago

Hey @letUser! I'll take a look at this this evening and see if we can find the problem.

avanc commented 3 years ago

I had the same problem. Using

const Horizons = require("@zachfejes/js-horizons");

instead of

 const { Horizons } = require("@zachfejes/js-horizons");

works.

mkandan commented 10 months ago

@zachfejes any update on this issue? neither const Horizons = require("@zachfejes/js-horizons"); nor const { Horizons } = require("@zachfejes/js-horizons"); (like your docs suggest) works