Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Rejection (TypeError): net.isIPv4 is not a function #306

Closed
zhg-kj opened this issue Jun 19, 2020 · 1 comment
Closed

Unhandled Rejection (TypeError): net.isIPv4 is not a function #306

zhg-kj opened this issue Jun 19, 2020 · 1 comment

Comments

@zhg-kj
Copy link

zhg-kj commented Jun 19, 2020

Hello, I am trying to use your geocoder in a for loop to loop over an array of markers in order to covert addresses to latitudes and longitudes on React. When I try to do this however, I receive the title error and the react app points towards this:

    const temp = await geocoder.geocode(markers[i].address)

I am not completely sure what that means, to me it seems like it does not recognize geocode as a function?

Here is the rest of the related code:

const NodeGeocoder = require('node-geocoder');
const options = {
    provider: 'google',
    apiKey: key
};
const geocoder = NodeGeocoder(options);
//unrelated code inbetween
let markers = [
    {
      name: "Costco Wholesale",
      address: "9151 Bridgeport Rd, Richmond, BC V6X 3L9",
      position: { lat: 49.166590, lng: -123.133569 },
      placeID: 'ChIJWc2NzuF0hlQRDu0NNhdQCjM'
    }
  ];
//Unrelated code inbetween
async findLatLong(){
    for(let i = 0; i < markers.length; i++){
        const temp = await geocoder.geocode(markers[i].address)
        markers[i].position.lat = temp.latitude;
        markers[i].position.lng = temp.longitude;
    }
  }

I apologize if it is a stupid mistake, I am still a JS noob, but I have definitely given it my best shot before posting here :/

TIA!

@zhg-kj
Copy link
Author

zhg-kj commented Jun 20, 2020

Changed it so that I am using the geocoder in my backend. Works like a charm.

@zhg-kj zhg-kj closed this as completed Jun 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant