davglass / zipcodes

Zipcode lookup node module
Other
157 stars 83 forks source link

Radius lookup bug #20

Open modernrockstar opened 6 years ago

modernrockstar commented 6 years ago

When using the radius lookup, it will return all the available zip codes for non-existent zip lookups.

For example '00000' or an invalid value an alpha-numeric string.

${this.state.userZipcode} = '000000' ${this.state.searchRadius} = '10'

const nearbyZipcodes = zipcodes.radius(${this.state.userZipcode}, ${this.state.searchRadius}); //returns 44K results

SunilHirole commented 6 years ago

@modernrockstar You can use lookup method to check whether zipcode exists or not. For example let isZipcodeExist = zipcodes.lookup(92084);

This method returns object like this. From this we can easily check whether zipcode exist or not {zip: "92084", latitude: 33.2131, longitude: -117.2243, city: "Vista", state: "CA","country:"US"}

This is just a workaround.

ChuckJonas commented 6 years ago

This also happens if you pass an actual Zipcode object in (instead of the #####). Extra confusing in typescript because the method signature specifics passing in the object instead of a string