21 lines
447 B
TypeScript
21 lines
447 B
TypeScript
/**
|
|
* Сервис для полуения csrt токена для размещения в формах
|
|
* @date 24.07.2025
|
|
* @author dgavrilov
|
|
*/
|
|
|
|
export const getCsrfToken = ():string => {
|
|
const METATAG:HTMLElement|null = document.querySelector('meta[name="csrf-token"]');
|
|
|
|
if (!METATAG) {
|
|
return '';
|
|
}
|
|
|
|
const CSRFTOKEN:string|null = METATAG.getAttribute('content');
|
|
if (!CSRFTOKEN) {
|
|
return '';
|
|
}
|
|
|
|
return CSRFTOKEN;
|
|
}
|