react_components_general #17
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* Сервис для полуения 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user