UNPKG

@dunite/check-access

Version:

Handles authentication for the corresponding AuthMiddle-nuget

50 lines (42 loc) 1.4 kB
// import { inject } from "aurelia-framework"; // import { HttpClient, json } from "aurelia-fetch-client"; // @inject(HttpClient) // export class DualiteHttp { // public http: HttpClient; // public cacheKey: string = "NoCacheKey"; // public projectId:string = "NoProjectId" // public baseUrl:string; // constructor(http: HttpClient) { // this.http = http; // } // public get(url: string): Promise<Response> { // this.configure(); // return this.http.fetch(url, { // method: "get" // }); // } // public post(url: string, body: any): Promise<Response> { // this.configure(); // //console.log(url, body); // return this.http.fetch(url, { // method: "post", // body: json(body) // }); // } // public configure() { // this.cacheKey = window.localStorage.getItem("cacheKey"); // this.projectId = window.localStorage.getItem("projectId"); // this.http.configure(config => { // config // .withBaseUrl(this.baseUrl) // .withDefaults({ // //credentials: "include", //Only for onprem where windows authentication is required // headers: { // "Accept": "application/json", // "CacheKey": this.cacheKey == null ? "" : this.cacheKey, // "ProjectID": this.projectId == null ? "" : this.projectId // } // }); // }); // } // }