@coscine/api-client 1.5.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/index.js +5 -30
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +5 -30
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/axios-basic.js +5 -30
- package/dist/lib/axios-basic.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -8602,15 +8602,15 @@
|
|
|
8602
8602
|
|
|
8603
8603
|
const instance = axios.create();
|
|
8604
8604
|
const authHeaderKey = 'Authorization';
|
|
8605
|
-
const
|
|
8605
|
+
const clientCorrelationIdKey = 'X-Coscine-Logging-CorrelationId';
|
|
8606
8606
|
function setHeader(request) {
|
|
8607
8607
|
if (typeof coscine !== "undefined") {
|
|
8608
8608
|
if (typeof coscine.authorization !== "undefined") {
|
|
8609
8609
|
request.headers.common[authHeaderKey] =
|
|
8610
8610
|
'Bearer ' + coscine.authorization.bearer;
|
|
8611
8611
|
}
|
|
8612
|
-
if (typeof coscine.
|
|
8613
|
-
request.headers.common[
|
|
8612
|
+
if (typeof coscine.clientcorrelation !== "undefined") {
|
|
8613
|
+
request.headers.common[clientCorrelationIdKey] = coscine.clientcorrelation.id;
|
|
8614
8614
|
}
|
|
8615
8615
|
}
|
|
8616
8616
|
if (typeof window !== 'undefined') {
|
|
@@ -8620,46 +8620,21 @@
|
|
|
8620
8620
|
request.headers.common[authHeaderKey] =
|
|
8621
8621
|
'Bearer ' + localStorageToken;
|
|
8622
8622
|
}
|
|
8623
|
-
const localStorageClientCorrelation = localStorage.getItem("coscine.
|
|
8623
|
+
const localStorageClientCorrelation = localStorage.getItem("coscine.clientcorrelation.id");
|
|
8624
8624
|
if (localStorageClientCorrelation) {
|
|
8625
|
-
request.headers.common[
|
|
8626
|
-
}
|
|
8627
|
-
}
|
|
8628
|
-
}
|
|
8629
|
-
function increaseLoading() {
|
|
8630
|
-
if ((typeof coscine !== "undefined") && (typeof coscine.loading !== "undefined") && (typeof coscine.loading.counter !== "undefined")) {
|
|
8631
|
-
coscine.loading.counter++;
|
|
8632
|
-
}
|
|
8633
|
-
if (typeof window !== 'undefined') {
|
|
8634
|
-
const localStorageLoading = localStorage.getItem("coscine.loading.counter");
|
|
8635
|
-
if (localStorageLoading) {
|
|
8636
|
-
localStorage.setItem("coscine.loading.counter", String(Number(localStorageLoading) + 1));
|
|
8637
|
-
}
|
|
8638
|
-
}
|
|
8639
|
-
}
|
|
8640
|
-
function decreaseLoading() {
|
|
8641
|
-
if ((typeof coscine !== "undefined") && (typeof coscine.loading !== "undefined") && (typeof coscine.loading.counter !== "undefined")) {
|
|
8642
|
-
coscine.loading.counter--;
|
|
8643
|
-
}
|
|
8644
|
-
if (typeof window !== 'undefined') {
|
|
8645
|
-
const localStorageLoading = localStorage.getItem("coscine.loading.counter");
|
|
8646
|
-
if (localStorageLoading) {
|
|
8647
|
-
localStorage.setItem("coscine.loading.counter", String(Number(localStorageLoading) - 1));
|
|
8625
|
+
request.headers.common[clientCorrelationIdKey] = localStorageClientCorrelation;
|
|
8648
8626
|
}
|
|
8649
8627
|
}
|
|
8650
8628
|
}
|
|
8651
8629
|
instance.interceptors.request.use((request) => {
|
|
8652
8630
|
setHeader(request);
|
|
8653
|
-
increaseLoading();
|
|
8654
8631
|
return request;
|
|
8655
8632
|
}, (error) => {
|
|
8656
8633
|
return Promise.reject(error);
|
|
8657
8634
|
});
|
|
8658
8635
|
instance.interceptors.response.use((response) => {
|
|
8659
|
-
decreaseLoading();
|
|
8660
8636
|
return response;
|
|
8661
8637
|
}, (error) => {
|
|
8662
|
-
decreaseLoading();
|
|
8663
8638
|
return Promise.reject(error);
|
|
8664
8639
|
});
|
|
8665
8640
|
|