I'm trying to write a simple web interface for Elasticsearch using Angular 2 and the official elasticsearch.js client from npm.
I've created a service like this:
import { Injectable } from '@angular/core';
import { Client } from 'elasticsearch';
@Injectable()
export class ElasticsearchService {
    private _client: Client;
    constructor() {
        if (!this._client) {
            this._connect();
        }
    };
    private _connect() {
        this._client = new Client({
            host: 'http://my-elasticsearch-host:9200',
            log: 'trace'
        });
    };
    isAvailable(): PromiseLike<String> {
        return this._client.ping({
            requestTimeout: Infinity
        });
    }
}
This seems to work fine. Logging shows me that requests are answered correctly.
Here's my component:
import { OnInit, Component } from '@angular/core';
import { ElasticsearchService } from './services/elasticsearch.service';
@Component({
    selector: 'foo',
    templateUrl: './foo.component.html',
    providers: [ElasticsearchService]
})
export class TimeLineComponent implements OnInit {
    private status: String = 'not ok';
    constructor(private esService: ElasticsearchService) { } ;
    ngOnInit(): void {
        this.showStatus();
    }
    showStatus(): void {
        this.esService.isAvailable()
            .then( response => this.status = 'OK' );
    }
}
and here's the template:
status:{{status}}
I don't understand why my browser keeps showing "not ok". What am I missing here?
 
     
    