mirror of
https://github.com/danbulant/Portfolio
synced 2026-05-24 12:35:31 +00:00
feat: admin ssr logout
This commit is contained in:
parent
245dcf43b5
commit
60e574d2b1
1 changed files with 18 additions and 0 deletions
|
|
@ -38,6 +38,24 @@ export const resetCandidatePassword = async (id: number): Promise<CreateCandidat
|
|||
}
|
||||
}
|
||||
|
||||
// SSR compatible
|
||||
// Logout as admin /admin/logout
|
||||
export const apiLogout = async (fetchSsr?: Fetch) => {
|
||||
try {
|
||||
if (fetchSsr) {
|
||||
const res = await fetchSsr(API_URL + '/admin/logout', {
|
||||
method: 'POST',
|
||||
credentials: 'include'
|
||||
});
|
||||
return await res.text();
|
||||
}
|
||||
const res = await axios.post(API_URL + '/admin/logout', { withCredentials: true });
|
||||
return res.data;
|
||||
} catch (e: any) {
|
||||
throw errorHandler(e, 'Logout failed');
|
||||
}
|
||||
};
|
||||
|
||||
// SSR compatible
|
||||
// List all candidates /admin/list/candidates
|
||||
export const apiListCandidates = async (fetchSsr?: Fetch): Promise<[CandidatePreview]> => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue