]>
Commit | Line | Data |
---|---|---|
230809ef C |
1 | import { Injectable } from '@angular/core'; |
2 | import { Http, Response } from '@angular/http'; | |
44124980 | 3 | import { Observable } from 'rxjs/Rx'; |
dc8bc31b C |
4 | |
5 | @Injectable() | |
41a2aee3 | 6 | export class FriendService { |
ccf6ed16 | 7 | private static BASE_FRIEND_URL: string = '/api/v1/pods/'; |
dc8bc31b C |
8 | |
9 | constructor (private http: Http) {} | |
10 | ||
11 | makeFriends() { | |
ccf6ed16 C |
12 | return this.http.get(FriendService.BASE_FRIEND_URL + 'makefriends') |
13 | .map(res => res.status) | |
dc8bc31b C |
14 | .catch(this.handleError); |
15 | } | |
16 | ||
17 | quitFriends() { | |
ccf6ed16 C |
18 | return this.http.get(FriendService.BASE_FRIEND_URL + 'quitfriends') |
19 | .map(res => res.status) | |
dc8bc31b C |
20 | .catch(this.handleError); |
21 | } | |
22 | ||
ccf6ed16 | 23 | private handleError (error: Response): Observable<number> { |
dc8bc31b C |
24 | console.error(error); |
25 | return Observable.throw(error.json().error || 'Server error'); | |
26 | } | |
27 | } |