import { Headers, Http, Response } from '@angular/http'; export abstract class CreateBaseService { protected abstract apiUrl: string; protected headers: Headers = new Headers({'Content-Type': 'applicaton/json'}); constructor(protected http: Http) { } getModels(): Promise { return this.http.get(this.apiUrl) .toPromise() .then((response: Response) => response.json()) .catch(this.handleError); } protected handleError(error: any): Promise { console.error('An error occured', error); return Promise.reject(error.message || error); } }