Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(private breezeBridgeAngularModule: BreezeBridgeAngularModule, private logger: Logger) {
super({
serviceName: Settings.serviceAppUrl + "/odata"
});
config.initializeAdapterInstance("uriBuilder", "odata");
// Use Web API OData to query and save
let adapter = config.initializeAdapterInstance("dataService", "webApiOData", true) as any;
adapter.getRoutePrefix = this.getRoutePrefix_Microsoft_AspNet_WebApi_OData_5_3_x;
// OData authorization interceptor
let oldClient = (window as any).OData.defaultHttpClient;
let newClient = {
request(request: any, success: any, error: any) {
request.headers = request.headers || {};
let tokenItem = localStorage.getItem("token");
let token = tokenItem ? JSON.parse(tokenItem.toString()) : null;
request.headers.Authorization = token !== null ? "Bearer " + token.access_token : "";
return oldClient.request(request, success, error);
}
};
(window as any).OData.defaultHttpClient = newClient;
// convert between server-side PascalCase and client-side camelCase
constructor(private breezeBridgeAngularModule: BreezeBridgeAngularModule, private logger: Logger) {
super({
serviceName: Settings.serviceAppUrl + "/odata"
});
config.initializeAdapterInstance("uriBuilder", "odata");
// Use Web API OData to query and save
let adapter = config.initializeAdapterInstance("dataService", "webApiOData", true) as any;
adapter.getRoutePrefix = this.getRoutePrefix_Microsoft_AspNet_WebApi_OData_5_3_x;
// OData authorization interceptor
let oldClient = (window as any).OData.defaultHttpClient;
let newClient = {
request(request: any, success: any, error: any) {
request.headers = request.headers || {};
let tokenItem = localStorage.getItem("token");
let token = tokenItem ? JSON.parse(tokenItem.toString()) : null;
request.headers.Authorization = token !== null ? "Bearer " + token.access_token : "";
return oldClient.request(request, success, error);
}
};