handle logout, #855

This commit is contained in:
Simon
2025-01-01 15:26:23 +07:00
parent 20e3b7b7ff
commit 86232b8628
5 changed files with 47 additions and 5 deletions

View 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;