From 41a2aee38cf812510010da09de9bae53590ec119 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 May 2016 16:23:10 +0200 Subject: Follow the angular styleguide for the directories structure --- client/app/friends/friend.service.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 client/app/friends/friend.service.ts (limited to 'client/app/friends/friend.service.ts') diff --git a/client/app/friends/friend.service.ts b/client/app/friends/friend.service.ts new file mode 100644 index 000000000..d143ec40d --- /dev/null +++ b/client/app/friends/friend.service.ts @@ -0,0 +1,27 @@ +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 => res.status) + .catch(this.handleError); + } + + quitFriends() { + return this.http.get(this._baseFriendsUrl + 'quitfriends') + .map(res => res.status) + .catch(this.handleError); + } + + private handleError (error: Response) { + console.error(error); + return Observable.throw(error.json().error || 'Server error'); + } +} -- cgit v1.2.3