mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
node api
This commit is contained in:
parent
cad4e683bc
commit
a662256221
4 changed files with 27 additions and 3 deletions
|
@ -5,4 +5,7 @@ export const API = {
|
|||
ME: '/auth/me', //
|
||||
UPLOAD: (target, type) => `/upload/${target}/${type}`,
|
||||
},
|
||||
NODE: {
|
||||
SAVE: '/node/',
|
||||
},
|
||||
};
|
||||
|
|
15
src/redux/node/api.ts
Normal file
15
src/redux/node/api.ts
Normal file
|
@ -0,0 +1,15 @@
|
|||
import { api, configWithToken, resultMiddleware, errorMiddleware } from '~/utils/api';
|
||||
import { INode } from '../types';
|
||||
import { API } from '~/constants/api';
|
||||
|
||||
export const postNode = ({
|
||||
access,
|
||||
data,
|
||||
}: {
|
||||
access: string,
|
||||
data: INode,
|
||||
}) => (
|
||||
api.post(API.NODE.SAVE, { data }, configWithToken(access))
|
||||
.then(resultMiddleware)
|
||||
.catch(errorMiddleware)
|
||||
);
|
|
@ -1,7 +1,10 @@
|
|||
import {
|
||||
IResultWithStatus, IFile, IUploadProgressHandler, IFileWithUUID,
|
||||
} from '~/redux/types';
|
||||
import { api, configWithToken } from '~/utils/api';
|
||||
import {
|
||||
api, configWithToken, resultMiddleware, errorMiddleware,
|
||||
} from '~/utils/api';
|
||||
|
||||
import { API } from '~/constants/api';
|
||||
|
||||
export const postUploadFile = ({
|
||||
|
@ -16,5 +19,8 @@ export const postUploadFile = ({
|
|||
const data = new FormData();
|
||||
data.append('file', file);
|
||||
|
||||
return api.post(API.USER.UPLOAD(target, type), data, configWithToken(access));
|
||||
return api
|
||||
.post(API.USER.UPLOAD(target, type), data, configWithToken(access))
|
||||
.then(resultMiddleware)
|
||||
.catch(errorMiddleware);
|
||||
};
|
||||
|
|
|
@ -18,6 +18,6 @@
|
|||
"~/*": ["src/*"]
|
||||
}
|
||||
},
|
||||
"include": ["./src/index.tsx", "./custom.d.ts"],
|
||||
"include": ["./src/**/*", "./custom.d.ts"],
|
||||
"exclude": ["./__tests__/**/*"]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue