mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-20 06:51:10 +00:00
feat: add admin whoami
This commit is contained in:
parent
f52673713f
commit
f4080f75b7
1 changed files with 16 additions and 0 deletions
|
|
@ -8,6 +8,22 @@ import type {
|
|||
import axios from 'axios';
|
||||
import { API_URL, errorHandler, type Fetch } from '.';
|
||||
|
||||
export const apiWhoami = async (fetchSsr?: Fetch): Promise<CreateCandidate> => {
|
||||
const apiFetch = fetchSsr || fetch;
|
||||
try {
|
||||
const res = await apiFetch(API_URL + '/admin/whoami', {
|
||||
method: 'GET',
|
||||
credentials: 'include'
|
||||
});
|
||||
if (res.status != 200) {
|
||||
throw Error(await res.text());
|
||||
}
|
||||
return await res.json();
|
||||
} catch (e) {
|
||||
throw errorHandler(e, 'Failed to fetch whoami');
|
||||
}
|
||||
};
|
||||
|
||||
// Login as admin /admin/login
|
||||
export const apiLogin = async (data: AdminLogin): Promise<number> => {
|
||||
try {
|
||||
|
|
|
|||
Loading…
Reference in a new issue