Batch geocoding with error handling NodeJS

Geocode several addresses in parallel from Node.js and report each failure by its SDK error code

CodeSandbox is a third-party service and may use cookies to see your IP address and browser info. Cookie notice

View on GitHub
Loading the sandbox…
SDK 1.0.0

Each address in the batch prints its match or why it failed, read from the error’s fields rather than its message.

  • SDKError carries a code and canRetry, so a bad request and a busy service are told apart by property, and SDKServiceError adds the HTTP status. geocodeOne finding nothing is a NOT_FOUND SDKError too.
  • Request validation rejects the latitude-first position before sending, naming the field in issues.
  • retry retries rate-limited calls with backoff, and one AbortSignal.timeout caps the whole batch.

Related examples