# Unable to display Appsearch data from frontend using javascript api (SwiftypeAppSearch)

**URL:** <https://discuss.elastic.co/t/unable-to-display-appsearch-data-from-frontend-using-javascript-api-swiftypeappsearch/162196>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [December 27, 2018, 4:57am UTC](https://discuss.elastic.co/t/unable-to-display-appsearch-data-from-frontend-using-javascript-api-swiftypeappsearch/162196 "2018-12-27T04:57:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![venu.pgi](https://avatars.discourse-cdn.com/v4/letter/v/3e96dc/32.png) [@venu.pgi](https://discuss.elastic.co/u/venu.pgi)\
**Post date:** [December 27, 2018, 4:57am UTC](https://discuss.elastic.co/t/unable-to-display-appsearch-data-from-frontend-using-javascript-api-swiftypeappsearch/162196/1 "2018-12-27T04:57:45Z")

</div>

we are evaluating the  
Elasticsearch / Appsearch to work with our MobileApp project for a US  
client. So I registered for the trail version and created a engine.

Also trying to connect to the Appsearch using the sample code given at  
the github.

> **[GitHub - swiftype/swiftype-app-search-javascript: Swiftype App Search...](https://github.com/swiftype/swiftype-app-search-javascript)**
>
> Swiftype App Search Javascript Client. Contribute to swiftype/swiftype-app-search-javascript development by creating an account on GitHub.

Attached is the test code we have written, using the approach given in  
the github. However it is not working giving some errors. I am  
attaching the code, errors and the credentials. Kindly forward to some  
one who can help us to integrate our MobileApp with your Appsearch  
product.

Here is the code with I am using:

> **[test.js.txt](https://drive.google.com/file/d/19x1bwagtockP8sYtYm6KBmLjr3cVJUZJ/view?usp=sharing)**
>
> Google Drive file.

And the error message can be seen here: [Erros.txt - Google Drive](https://drive.google.com/file/d/1luD2qVZl1zZnX7CFcv4b6gSnppqPqYBO/view?usp=sharing)

Secondly, we are really looking for a example app code with a  
searchbox which can connect to your Appsearch Engine and get some  
results. Kindly help us with an example.

---

<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:** [January 2, 2019, 3:08pm UTC](https://discuss.elastic.co/t/unable-to-display-appsearch-data-from-frontend-using-javascript-api-swiftypeappsearch/162196/2 "2019-01-02T15:08:41Z")

</div>

Hey @venu.pgi.

You're receiving the error because whatever environment you're running the client in does not support the Fetch API. The javascript client expects to be run in modern browsers that support [https://developer.mozilla.org/en-US/docs/Web/API/Fetch\_API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)

However, depending on your environment, the workaround is fairly straight forward. You can simply polyfill the fetch API.  
We use [https://github.com/bitinn/node-fetch](https://github.com/bitinn/node-fetch) in our test suite. [https://github.com/github/fetch](https://github.com/github/fetch) looks viable as well.

I'm not sure what technology you're using in your mobile app, but assuming it's something like React Native, then I think this would be a great reference to use:  
[https://swiftype.com/documentation/app-search/tutorials/react](https://swiftype.com/documentation/app-search/tutorials/react).

Additionally, there's the Reference UI, which could serve as a reasonable code example: [https://swiftype.com/documentation/app-search/guides/reference-ui](https://swiftype.com/documentation/app-search/guides/reference-ui).

I'd be curious to know if you find any of that useful. Let us know if not, we could probably find something else more suited to your needs.

---

<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 30, 2019, 3:08pm UTC](https://discuss.elastic.co/t/unable-to-display-appsearch-data-from-frontend-using-javascript-api-swiftypeappsearch/162196/3 "2019-01-30T15:08:52Z")

</div>

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