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

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.

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:
https://drive.google.com/file/d/19x1bwagtockP8sYtYm6KBmLjr3cVJUZJ/view?usp=sharing

And the error message can be seen here: 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.

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

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 in our test suite. 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.

Additionally, there's the Reference UI, which could serve as a reasonable code example: 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.

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