feat: похуйу
This commit is contained in:
21
src/features/auth/api/profileApi.ts
Normal file
21
src/features/auth/api/profileApi.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { getCsrfToken } from '@shared/api/csrf'
|
||||
import { tokenStore } from '@shared/api/tokenStore'
|
||||
|
||||
const USERS_API_URL = 'https://app.users.elcsa.ru'
|
||||
|
||||
export async function getMe(): Promise<unknown> {
|
||||
const csrf = await getCsrfToken()
|
||||
const bearer = tokenStore.get()
|
||||
|
||||
const res = await fetch(`${USERS_API_URL}/me`, {
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'X-CSRF-Token': csrf,
|
||||
...(bearer ? { Authorization: `Bearer ${bearer}` } : {}),
|
||||
},
|
||||
})
|
||||
|
||||
const data = await res.json()
|
||||
if (!res.ok) throw data
|
||||
return data
|
||||
}
|
||||
Reference in New Issue
Block a user