aboutsummaryrefslogblamecommitdiffhomepage
path: root/client/app/friends/friend.service.ts
blob: d143ec40d07b83282a9d0f8db0ea20dc8a4281fa (plain) (tree)
1
2
3
4
5
6

                                               
                                     

             
                            




















                                                                  
import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Rx';

@Injectable()
export class FriendService {
  private _baseFriendsUrl = '/api/v1/pods/';

  constructor (private http: Http) {}

  makeFriends() {
    return this.http.get(this._baseFriendsUrl + 'makefriends')
                    .map(res => <number> res.status)
                    .catch(this.handleError);
  }

  quitFriends() {
    return this.http.get(this._baseFriendsUrl + 'quitfriends')
                    .map(res => <number> res.status)
                    .catch(this.handleError);
  }

  private handleError (error: Response) {
    console.error(error);
    return Observable.throw(error.json().error || 'Server error');
  }
}