Skip to content
Snippets Groups Projects
Commit 4ded71a4 authored by Benedikt Heinrichs's avatar Benedikt Heinrichs
Browse files

Small Header fix

parent a42e82d1
No related branches found
No related tags found
1 merge request!1New: Create a generated api client
import axios from 'axios';
import axios, { AxiosRequestConfig } from 'axios';
const instance = axios.create();
const authHeaderKey = 'Authorization';
const clientCorrolationIdKey = 'X-Coscine-Logging-CorrelationId';
function setHeader() {
function setHeader(request: AxiosRequestConfig) {
if (typeof coscine !== "undefined") {
instance.defaults.headers.common[authHeaderKey] =
request.headers.common[authHeaderKey] =
'Bearer ' + coscine.authorization.bearer;
instance.defaults.headers.common[clientCorrolationIdKey] = coscine.clientcorrolation.id;
request.headers.common[clientCorrolationIdKey] = coscine.clientcorrolation.id;
}
};
instance.interceptors.request.use((request: unknown) => {
setHeader();
instance.interceptors.request.use((request: AxiosRequestConfig) => {
setHeader(request);
if ((typeof coscine !== "undefined") && (typeof coscine.loading !== "undefined") && (typeof coscine.loading.counter !== "undefined")) {
coscine.loading.counter++;
}
......@@ -23,7 +23,7 @@ instance.interceptors.request.use((request: unknown) => {
return Promise.reject(error);
});
instance.interceptors.response.use((response: unknown) => {
instance.interceptors.response.use((response: AxiosRequestConfig) => {
if ((typeof coscine !== "undefined") && (typeof coscine.loading !== "undefined") && (typeof coscine.loading.counter !== "undefined")) {
coscine.loading.counter--;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment