1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00
This commit is contained in:
muerwre 2019-08-22 20:43:21 +07:00
parent cad4e683bc
commit a662256221
4 changed files with 27 additions and 3 deletions

View file

@ -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
View 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)
);

View file

@ -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);
};

View file

@ -18,6 +18,6 @@
"~/*": ["src/*"]
}
},
"include": ["./src/index.tsx", "./custom.d.ts"],
"include": ["./src/**/*", "./custom.d.ts"],
"exclude": ["./__tests__/**/*"]
}