openaire-library/services/servicesUtils/customOptions.class.ts

45 lines
1.3 KiB
TypeScript

import {COOKIE} from '../../login/utils/helper.class';
import {HttpHeaders} from "@angular/common/http";
export class CustomOptions {
/*
public static getAuthOptionsWithBody(): RequestOptions {
const headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('X-XSRF-TOKEN', COOKIE.getCookie(COOKIE.cookieName_id));
const options = new RequestOptions({ headers: headers, withCredentials: true });
return options;
}
*/
public static getAuthOptionsWithBody():{} {
return {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'X-XSRF-TOKEN': COOKIE.getCookie(COOKIE.cookieName_id)?COOKIE.getCookie(COOKIE.cookieName_id):''
}), withCredentials: true
};
}
/*
public static getAuthOptions(): RequestOptions {
const headers = new Headers();
headers.append('X-XSRF-TOKEN', COOKIE.getCookie(COOKIE.cookieName_id));
const options = new RequestOptions({ headers: headers, withCredentials: true });
return options;
}
*/
public static getAuthOptions():any {
const httpOptions = {
headers: new HttpHeaders({
'X-XSRF-TOKEN': (COOKIE.getCookie(COOKIE.cookieName_id))?COOKIE.getCookie(COOKIE.cookieName_id):'',
}), withCredentials: true
};
return httpOptions;
}
}