Commit 1e53fdfd authored by Samir Sadyhov's avatar Samir Sadyhov 🤔

ApiClient fix auth

parent 6342dc30
this.ApiClient = class { this.ApiClient = class {
constructor() { constructor() {
this._baseURL = `${window.location.origin}/Synergy`; this._baseURL = `${window.location.origin}/Synergy`;
this._authHeader = this._buildAuthHeader();
this._defaultAuthHeader = this._buildDefaultAuthHeader();
this._requestInterceptors = []; this._requestInterceptors = [];
this._responseInterceptors = []; this._responseInterceptors = [];
} }
async request({ url, method = 'GET', body, headers = {}, defaultUser = false }) { async request({ url, method = 'GET', body, headers = {}, defaultUser = false }) {
let finalHeaders = this._normalizeHeaders({ let finalHeaders = this._normalizeHeaders({
authorization: defaultUser ? this._defaultAuthHeader : this._authHeader, authorization: defaultUser ? this._buildDefaultAuthHeader() : this._buildAuthHeader(),
...headers, ...headers,
}); });
...@@ -57,7 +54,6 @@ this.ApiClient = class { ...@@ -57,7 +54,6 @@ this.ApiClient = class {
try { try {
response = await fetch(config.url, config); response = await fetch(config.url, config);
} catch (err) { } catch (err) {
console.error({config, msg: err});
throw this._handleNetworkError(err); throw this._handleNetworkError(err);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment