]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/app/friends/friend.service.ts
Follow the angular styleguide for the directories structure
[github/Chocobozzz/PeerTube.git] / client / app / friends / friend.service.ts
CommitLineData
230809ef
C
1import { Injectable } from '@angular/core';
2import { Http, Response } from '@angular/http';
44124980 3import { Observable } from 'rxjs/Rx';
dc8bc31b
C
4
5@Injectable()
41a2aee3 6export class FriendService {
dc8bc31b
C
7 private _baseFriendsUrl = '/api/v1/pods/';
8
9 constructor (private http: Http) {}
10
11 makeFriends() {
12 return this.http.get(this._baseFriendsUrl + 'makefriends')
13 .map(res => <number> res.status)
14 .catch(this.handleError);
15 }
16
17 quitFriends() {
18 return this.http.get(this._baseFriendsUrl + 'quitfriends')
19 .map(res => <number> res.status)
20 .catch(this.handleError);
21 }
22
23 private handleError (error: Response) {
24 console.error(error);
25 return Observable.throw(error.json().error || 'Server error');
26 }
27}