mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
getting token / error
This commit is contained in:
parent
956802d5a5
commit
dc6f72baf1
26 changed files with 269 additions and 374 deletions
15
src/redux/auth/api.ts
Normal file
15
src/redux/auth/api.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import {api, authMiddleware, errorMiddleware, resultMiddleware} from "~/utils/api";
|
||||
import { API } from "~/constants/api";
|
||||
import { IApiUser } from "~/redux/auth/constants";
|
||||
import {IResultWithStatus} from "~/redux/types";
|
||||
import {userLoginTransform} from "~/redux/auth/transforms";
|
||||
|
||||
export const apiUserLogin = (
|
||||
{ username, password }:
|
||||
{ username: string, password: string }
|
||||
): Promise<IResultWithStatus<{ token: string, status?: number, user?: IApiUser }>> => (
|
||||
api.post(API.USER.LOGIN, { username, password })
|
||||
.then(resultMiddleware)
|
||||
.catch(errorMiddleware)
|
||||
.then(userLoginTransform)
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue