import { Observable } from "rxjs/Observable"; import { SessionStorage } from "../SessionStorage"; import { HttpClient } from "@angular/common/http"; export class AuthedApi { constructor(protected http: HttpClient) { } protected authedGet(url: string, qs?: any): Observable { if (!qs) qs = {}; qs["scalar_token"] = SessionStorage.scalarToken; return this.http.get(url, {params: qs}); } protected authedPost(url: string, body?: any): Observable { if (!body) body = {}; const qs = {scalar_token: SessionStorage.scalarToken}; return this.http.post(url, body, {params: qs}); } protected authedDelete(url: string, qs?: any): Observable { if (!qs) qs = {}; qs["scalar_token"] = SessionStorage.scalarToken; return this.http.delete(url, {params: qs}); } }