smarty / smartystreets-javascript-sdk

The official client libraries for accessing SmartyStreets APIs from javascript.
https://smartystreets.com/docs/sdk/javascript
Apache License 2.0
31 stars 30 forks source link

US Autocomplete API throwing Error #57

Closed tfoxley closed 2 years ago

tfoxley commented 2 years ago

I am consistently getting the following error when attempting to use the UsAutocompleteProClient.

ERROR Error: Uncaught (in promise): TypeError: Cannot read properties of undefined (reading 'map')
TypeError: Cannot read properties of undefined (reading 'map')
    at buildSuggestionsFromResponse (Client.js:56:31)

It appears that this function is checking for the payload.suggestions to be null but it should also be doing a check for undefined.

function buildSuggestionsFromResponse(payload) {
  if (payload.suggestions === null) return [];
  return payload.suggestions.map(suggestion => new Suggestion(suggestion));
}

I was essentially attempting to use a simple example like what can be found at https://github.com/smarty/smartystreets-javascript-sdk/blob/master/examples/us_autocomplete_pro.js