initial
This commit is contained in:
30
frontend/src/api/auth.ts
Normal file
30
frontend/src/api/auth.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import client from './client'
|
||||
import type { TokenResponse, User } from '@/types'
|
||||
|
||||
export interface RegisterData {
|
||||
login: string
|
||||
password: string
|
||||
nickname: string
|
||||
}
|
||||
|
||||
export interface LoginData {
|
||||
login: string
|
||||
password: string
|
||||
}
|
||||
|
||||
export const authApi = {
|
||||
register: async (data: RegisterData): Promise<TokenResponse> => {
|
||||
const response = await client.post<TokenResponse>('/auth/register', data)
|
||||
return response.data
|
||||
},
|
||||
|
||||
login: async (data: LoginData): Promise<TokenResponse> => {
|
||||
const response = await client.post<TokenResponse>('/auth/login', data)
|
||||
return response.data
|
||||
},
|
||||
|
||||
me: async (): Promise<User> => {
|
||||
const response = await client.get<User>('/auth/me')
|
||||
return response.data
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user