1 import { Injectable } from '@angular/core';
2 import { Response } from '@angular/http';
3 import { Observable } from 'rxjs/Observable';
5 import { Friend } from './friend.model';
6 import { AuthHttp, AuthService } from '../../../shared';
9 export class FriendService {
10 private static BASE_FRIEND_URL: string = '/api/v1/pods/';
13 private authHttp: AuthHttp,
14 private authService: AuthService
17 getFriends(): Observable<Friend[]> {
18 return this.authHttp.get(FriendService.BASE_FRIEND_URL)
19 .map(res => <Friend[]>res.json())
20 .catch(this.handleError);
24 return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'makefriends')
25 .map(res => res.status)
26 .catch(this.handleError);
30 return this.authHttp.get(FriendService.BASE_FRIEND_URL + 'quitfriends')
31 .map(res => res.status)
32 .catch(this.handleError);
35 private handleError (error: Response) {
37 return Observable.throw(error.json().error || 'Server error');