blob: 2b71d7a019c690ce9b157c065dfae75a9c1f0283 [file] [log] [blame]
Matteo Scandolo40f8fa92016-12-07 09:21:35 -08001/// <reference path="../../../../typings/index.d.ts"/>
2
3// Imports
4import {AppConfig} from '../../config/app.config';
5import { Injectable } from '@angular/core';
6import { Response} from '@angular/http';
7import {XosHttp} from './xoshttp.service';
8import {Observable} from 'rxjs/Rx';
9
10// Import RxJs required methods
11import 'rxjs/add/operator/map';
12import 'rxjs/add/operator/catch';
13
14@Injectable()
15export 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}