Skip to content

Instantly share code, notes, and snippets.

@brunokrebs
Created March 2, 2017 14:28
Show Gist options
  • Save brunokrebs/7c566da11998d69bce578bc55174aa58 to your computer and use it in GitHub Desktop.
Save brunokrebs/7c566da11998d69bce578bc55174aa58 to your computer and use it in GitHub Desktop.
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { AuthHttp } from 'angular2-jwt';
@Injectable()
export class TaskListService {
private static TASKS_ENDPOINT =
'https://wt-e1870b8a73b27cdee73c468b8c8e3bc4-0.run.webtask.io/tasks';
constructor(private authHttp: AuthHttp) { }
loadTasks$(): Observable<any> {
return this.authHttp.get(TaskListService.TASKS_ENDPOINT);
}
addTask$(task) : Observable<any> {
return this.authHttp.post(TaskListService.TASKS_ENDPOINT,
{ description: task });
}
deleteTask$(task): Observable<any> {
return this.authHttp.delete(TaskListService.TASKS_ENDPOINT +
'?id=' + task._id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment