GraphHopper.com | Forum | GitHub | Maps | Blog

Graphhopper run time error “GraphHopperRouting is not a constructor”


#1

I wanted to use graphhopper js client in my Ionic app, so following the instructions explained here I have installed the package using npm, then tried to use the routing API.
All I did was import this:

import {graphhopper, GraphHopperRouting, GHInput} from 'graphhopper-js-api-client';

And then wrote:

var defaultKey = "[key]";
var profile = "foot";
var host;
var ghRouting = new GraphHopperRouting({key: defaultKey, host: host, vehicle:profile,elevation:false})

ghRouting.addPoint(new GHInput(47.400905, 8.534317));
 ghRouting.addPoint(new GHInput(47.394108, 8.538265));

 ghRouting.doRequest().then(function(json){
   console.log("Result: " + json)
 }).catch(function(err){
   console.log(err.message)
 })

Exactly as the guide explained.
When I run the code, the following error is shown:

Runtime Error
 __WEBPACK_IMPORTED_MODULE_6_graphhopper_js_api_client__.GraphHopperRouting is not a constructor

#2

Crossposted here