# SearchBox AutoComplete throws unhandled rejection error

**URL:** <https://discuss.elastic.co/t/searchbox-autocomplete-throws-unhandled-rejection-error/291895>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [December 15, 2021, 4:24am UTC](https://discuss.elastic.co/t/searchbox-autocomplete-throws-unhandled-rejection-error/291895 "2021-12-15T04:24:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mecadamia.nut](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@Mecadamia.nut](https://discuss.elastic.co/u/Mecadamia.nut)\
**Post date:** [December 15, 2021, 4:24am UTC](https://discuss.elastic.co/t/searchbox-autocomplete-throws-unhandled-rejection-error/291895/1 "2021-12-15T04:24:50Z")

</div>

I'm using the searchbox and i'm getting below error for the code below. what am i missing?

Unhandled Rejection (TypeError): Cannot read properties of undefined (reading 'request\_id')

(anonymous function)

C:/workspaces/ortho/ORTHO\_CLINICAL\_GlobalB2BPortal\_AZURE\_REPO/src/AppSearchAPIConnector.js:171

```auto
  168 | this.beforeAutocompleteSuggestionsCall(options, newOptions =>  
  169 | this.client.querySuggestion(searchTerm, newOptions).then(response => {  
  170 | autocompletedState.autocompletedSuggestions = response.results;> 
  171 | autocompletedState.autocompletedSuggestionsRequestId =  
      | ^  
  172 | response.meta.request_id;  
  173 | })  
  174 | )

```

```auto
                        <SearchBox
                            autocompleteResults={{titleField: "title",urlField: "nps_link"}}
                            shouldClearFilters={false}
                            autocompleteSuggestions={true}
                            debounceLength={4}
                            autocompleteMinimumCharacters={4}
                            onSubmit={searchTerm => setSearchTerm(searchTerm)}
                            onSelectAutocomplete={(selection, { }, defaultOnSelectAutocomplete) => {
                                if (selection.suggestion) {
                                    setSearchTerm(selection.suggestion);
                                } else {
                                    defaultOnSelectAutocomplete(selection);
                                }
                            }}
                        />

```

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [December 16, 2021, 12:48pm UTC](https://discuss.elastic.co/t/searchbox-autocomplete-throws-unhandled-rejection-error/291895/2 "2021-12-16T12:48:05Z")

</div>

Interesting. Are you able to capture the API request and response using your browser's network inspector?

---

<div class="post-metadata">

**Author:** ![Mecadamia.nut](https://avatars.discourse-cdn.com/v4/letter/m/e79b87/32.png) [@Mecadamia.nut](https://discuss.elastic.co/u/Mecadamia.nut)\
**Post date:** [December 16, 2021, 6:31pm UTC](https://discuss.elastic.co/t/searchbox-autocomplete-throws-unhandled-rejection-error/291895/3 "2021-12-16T18:31:27Z")

</div>

Hi Jason,  
Unfortunately i haven't captured the request and response for this and now i cannot reproduce the issue anymore. Thanks for checking.

---

<div class="post-metadata">

**Author:** ![JasonStoltz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonstoltz/32/49893_2.png) [@JasonStoltz](https://discuss.elastic.co/u/JasonStoltz)\
**Post date:** [December 17, 2021, 9:23pm UTC](https://discuss.elastic.co/t/searchbox-autocomplete-throws-unhandled-rejection-error/291895/4 "2021-12-17T21:23:35Z")

</div>

Ah ok. Perhaps the front-end code was failing to handle an error response correctly.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 14, 2022, 9:24pm UTC](https://discuss.elastic.co/t/searchbox-autocomplete-throws-unhandled-rejection-error/291895/5 "2022-01-14T21:24:19Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
