nodram
Version:
A Really MEAN Web Framework
30 lines (23 loc) • 663 B
text/typescript
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/throw';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import { CacheService } from './cache.service';
()
export class ApiService {
constructor(public _http: Http) {
}
/**
* whatever domain/feature method name
*/
get(url: string, options?: any) {
return this._http.get(url, options)
.map(res => res.json())
.catch(err => {
console.log('Error: ', err);
return Observable.throw(err);
});
}
}