PeerTube/client/app/friends/friend.service.ts

28 lines
805 B
TypeScript
Raw Normal View History

2016-05-13 07:18:37 -05:00
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
2016-04-08 13:58:07 -05:00
import { Observable } from 'rxjs/Rx';
2016-03-14 07:50:19 -05:00
@Injectable()
export class FriendService {
2016-05-27 10:25:52 -05:00
private static BASE_FRIEND_URL: string = '/api/v1/pods/';
2016-03-14 07:50:19 -05:00
constructor (private http: Http) {}
makeFriends() {
2016-05-27 10:25:52 -05:00
return this.http.get(FriendService.BASE_FRIEND_URL + 'makefriends')
.map(res => res.status)
2016-03-14 07:50:19 -05:00
.catch(this.handleError);
}
quitFriends() {
2016-05-27 10:25:52 -05:00
return this.http.get(FriendService.BASE_FRIEND_URL + 'quitfriends')
.map(res => res.status)
2016-03-14 07:50:19 -05:00
.catch(this.handleError);
}
2016-05-27 10:25:52 -05:00
private handleError (error: Response): Observable<number> {
2016-03-14 07:50:19 -05:00
console.error(error);
return Observable.throw(error.json().error || 'Server error');
}
}