# Elasticsearch js client for Angular2+

**URL:** <https://discuss.elastic.co/t/elasticsearch-js-client-for-angular2/93962>\
**Category:** Elasticsearch\
**Created:** [July 20, 2017, 2:28pm UTC](https://discuss.elastic.co/t/elasticsearch-js-client-for-angular2/93962 "2017-07-20T14:28:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![automotiveace](https://avatars.discourse-cdn.com/v4/letter/a/a3d4f5/32.png) [@automotiveace](https://discuss.elastic.co/u/automotiveace)\
**Post date:** [July 20, 2017, 2:28pm UTC](https://discuss.elastic.co/t/elasticsearch-js-client-for-angular2/93962/1 "2017-07-20T14:28:57Z")

</div>

I'm trying to figure out how to connect Elastic 5.x with Angular 4. The thing that has me all confused is that I know with AngularJS and Elasticsearch 1.x and 2.x, the AngularJS client used promises to communicate with ES. Now Angular uses Observables and I don't quite know how to make that work with Angular client for ES 5.x??

I got this code from github support thread of Elastic repo

```
public test_search(): Observable<SearchResponse<{}>> {
    return Observable.fromPromise(<Promise<SearchResponse<{}>>> this.clientElasticsearch.search( {
      index: '3entreprises',
      q: `Customer:0`
    }));
  }

```

The first two lines have me confused and I'm not quite sure what they actually do?

---

<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:** [August 17, 2017, 2:29pm UTC](https://discuss.elastic.co/t/elasticsearch-js-client-for-angular2/93962/2 "2017-08-17T14:29:08Z")

</div>

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