Blame view

src/services/service-object-create.service.ts 724 Bytes
c680f5b4   Administrator   first commit
1
2
3
4
5
  import { Injectable } from '@angular/core';
  import { Headers, Http } from '@angular/http';
  
  import 'rxjs/add/operator/toPromise';
  
c680f5b4   Administrator   first commit
6
  @Injectable()
74a2441c   Administrator   Add ServiceObject
7
8
  export class ServiceObjectCreateService {
      private apiUrl = 'http://localhost:5000/serviceobject/directory';
c680f5b4   Administrator   first commit
9
10
      private headers = new Headers({'Content-Type': 'applicaton/json'});
      constructor(private http: Http) { }
74a2441c   Administrator   Add ServiceObject
11
      getModels(): Promise<any> {
c680f5b4   Administrator   first commit
12
13
          return this.http.get(this.apiUrl)
              .toPromise()
74a2441c   Administrator   Add ServiceObject
14
              .then(response => response.json())
c680f5b4   Administrator   first commit
15
16
17
18
19
20
21
              .catch(this.handleError);
      }
      private handleError(error: any): Promise<any> {
          console.error('An error occured', error);
          return Promise.reject(error.message || error);
      }
  }