user.ts 517 B

1234567891011121314151617181920212223242526272829
  1. import { API } from '../api'
  2. import type { UserData } from '~/types/userData'
  3. interface TLoginReq {
  4. login: string
  5. password: string
  6. }
  7. interface TLoginRes {
  8. access_token: string
  9. user_id: number
  10. }
  11. class UserModule extends API {
  12. async getInfo(access_token: string) {
  13. return await this.get<UserData>(
  14. `/user/info?access_token=${access_token}`,
  15. )
  16. }
  17. async login(data: TLoginReq) {
  18. return await this.post<TLoginRes>(
  19. `/user/login`,
  20. data,
  21. )
  22. }
  23. }
  24. export default UserModule