I have this Axios request:
public getData<ResponseEntity = any>(path: string, config?: AxiosRequestConfig) {
return this.axiosInstance.get<ResponseEntity>(path, {
headers: {
'x-b3-traceid': traceId,
'x-b3-spanid': searchId(),
},
...config,
});
}
I’d like to make a request where I first parse one of the cookies and send it as a custom header. The below parses the cookie. How do I add it as a header and not overwrite the existing headers that get added?
getCook(cookiename: string) {
// Get name followed by anything except a semicolon
var cookiestring = RegExp(cookiename + '=[^;]+').exec(document.cookie);
// Return everything after the equal sign, or an empty string if the cookie name not found
return decodeURIComponent(!!cookiestring ? cookiestring.toString().replace(/^[^=]+./, '') : '');
}
getCert(policy: string): Promise<string> {
// default timeout overridden. set to 3 mins for this call as it can be slow to respond
const cook = this.getCook('mycookie');
return ApiService.getData(this.apiUrl + policy + this.certEndpoint).then(
(response) => response.data
);
}

