# Connecting and fetching elasticsearch from react Js

**URL:** <https://discuss.elastic.co/t/connecting-and-fetching-elasticsearch-from-react-js/316955>\
**Category:** Elasticsearch\
**Created:** [October 19, 2022, 6:59am UTC](https://discuss.elastic.co/t/connecting-and-fetching-elasticsearch-from-react-js/316955 "2022-10-19T06:59:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pravu](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@pravu](https://discuss.elastic.co/u/pravu)\
**Post date:** [October 19, 2022, 6:59am UTC](https://discuss.elastic.co/t/connecting-and-fetching-elasticsearch-from-react-js/316955/1 "2022-10-19T06:59:44Z")

</div>

Hello,

Would it be possible or is there any library available in javascript to connect and fetch data from elasticsearch index by providing json as input which elasticserver understand.

regards,

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [October 19, 2022, 7:06am UTC](https://discuss.elastic.co/t/connecting-and-fetching-elasticsearch-from-react-js/316955/2 "2022-10-19T07:06:50Z")

</div>

Have you looked at [the official client](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/index.html)?

---

<div class="post-metadata">

**Author:** ![pravu](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@pravu](https://discuss.elastic.co/u/pravu)\
**Post date:** [October 19, 2022, 7:10am UTC](https://discuss.elastic.co/t/connecting-and-fetching-elasticsearch-from-react-js/316955/3 "2022-10-19T07:10:38Z")

</div>

yes, it says the following in "introduction".

This is the official **Node.js** client for Elasticsearch. This page gives a quick overview about the features of the client.

I need to use J2EE server and would like to write javascript in clientside and not in "Node.js" side..

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 19, 2022, 7:16am UTC](https://discuss.elastic.co/t/connecting-and-fetching-elasticsearch-from-react-js/316955/4 "2022-10-19T07:16:46Z")

</div>

Welcome!

I'd not recommend connecting Elasticsearch from the frontend TBH. That would require to have the frontend aware of the credentials...

Why not doing the backend connection from the backend (your JEE app) and then send to the frontend only what is needed or the full response as a JSON...

See for example:

> <https://github.com/dadoonet/legacy-search/blob/60f17334f6fc8fd3d5a4d7162fa59ca0fe4e72c6/src/main/java/fr/pilato/demo/legacysearch/dao/ElasticsearchDao.java#L155>

---

<div class="post-metadata">

**Author:** ![pravu](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@pravu](https://discuss.elastic.co/u/pravu)\
**Post date:** [October 19, 2022, 7:39am UTC](https://discuss.elastic.co/t/connecting-and-fetching-elasticsearch-from-react-js/316955/5 "2022-10-19T07:39:36Z")

</div>

Thanks. Agree that, it is not safe to connect from frontend. But still would like to know if there is any library exists to connect from frontend( Javascript).

---

<div class="post-metadata">

**Author:** ![pravu](https://avatars.discourse-cdn.com/v4/letter/p/e480ec/32.png) [@pravu](https://discuss.elastic.co/u/pravu)\
**Post date:** [October 19, 2022, 7:44am UTC](https://discuss.elastic.co/t/connecting-and-fetching-elasticsearch-from-react-js/316955/6 "2022-10-19T07:44:54Z")

</div>

May I know the Java library location from where to download, that need to be used in serverside rest API.

---

<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:** [November 16, 2022, 7:45am UTC](https://discuss.elastic.co/t/connecting-and-fetching-elasticsearch-from-react-js/316955/7 "2022-11-16T07:45:18Z")

</div>

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