mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-07 18:19:31 +00:00
handle logout, #855
This commit is contained in:
22
frontend/src/api/actions/logOut.ts
Normal file
22
frontend/src/api/actions/logOut.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import defaultHeaders from '../../configuration/defaultHeaders';
|
||||
import getApiUrl from "../../configuration/getApiUrl"
|
||||
import getFetchCredentials from "../../configuration/getFetchCredentials";
|
||||
import getCookie from "../../functions/getCookie";
|
||||
|
||||
const logOut = async () => {
|
||||
const apiUrl = getApiUrl();
|
||||
const csrfCookie = getCookie('csrftoken');
|
||||
|
||||
const response = await fetch(`${apiUrl}/api/user/logout/`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...defaultHeaders,
|
||||
'X-CSRFToken': csrfCookie || '',
|
||||
},
|
||||
credentials: getFetchCredentials(),
|
||||
})
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
export default logOut;
|
||||
Reference in New Issue
Block a user