Matteo Scandolo | 40f8fa9 | 2016-12-07 09:21:35 -0800 | [diff] [blame^] | 1 | /// <reference path="../../../../typings/index.d.ts"/> |
| 2 | |
| 3 | // Imports |
| 4 | import {AppConfig} from '../../config/app.config'; |
| 5 | import { Injectable } from '@angular/core'; |
| 6 | import { Response} from '@angular/http'; |
| 7 | import {XosHttp} from './xoshttp.service'; |
| 8 | import {Observable} from 'rxjs/Rx'; |
| 9 | |
| 10 | // Import RxJs required methods |
| 11 | import 'rxjs/add/operator/map'; |
| 12 | import 'rxjs/add/operator/catch'; |
| 13 | |
| 14 | @Injectable() |
| 15 | export class SliceService { |
| 16 | private baseUrl = AppConfig.apiEndpoint; |
| 17 | constructor (private http: XosHttp) {} |
| 18 | // Fetch all existing instances |
| 19 | query() : Observable<any[]> { |
| 20 | return this.http.get(`${this.baseUrl}/core/slices/`) |
| 21 | .map((res: Response) => res.json()) |
| 22 | .catch((error: any) => Observable.throw(error.response.json().error || 'Server error')); |
| 23 | } |
| 24 | } |