1 import { Injectable } from '@angular/core';
2 import { Http, Response } from '@angular/http';
3 import { Observable } from 'rxjs/Rx';
5 import { AuthService } from '../shared';
8 export class FriendService {
9 private static BASE_FRIEND_URL: string = '/api/v1/pods/';
11 constructor (private http: Http, private authService: AuthService) {}
14 const headers = this.authService.getRequestHeader();
15 return this.http.get(FriendService.BASE_FRIEND_URL + 'makefriends', { headers })
16 .map(res => res.status)
17 .catch(this.handleError);
21 const headers = this.authService.getRequestHeader();
22 return this.http.get(FriendService.BASE_FRIEND_URL + 'quitfriends', { headers })
23 .map(res => res.status)
24 .catch(this.handleError);
27 private handleError (error: Response): Observable<number> {
29 return Observable.throw(error.json().error || 'Server error');