mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-24 20:36:40 +07:00
added api call (not working)
This commit is contained in:
parent
92f097d161
commit
7350201e22
3 changed files with 26 additions and 2 deletions
|
@ -3,5 +3,6 @@ export const API = {
|
|||
USER: {
|
||||
LOGIN: '/auth/login',
|
||||
ME: '/auth/me', //
|
||||
}
|
||||
UPLOAD: (target, type) => `/upload/${target}/${type}`,
|
||||
},
|
||||
};
|
||||
|
|
20
src/redux/uploads/api.ts
Normal file
20
src/redux/uploads/api.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { IResultWithStatus, IFile } from '~/redux/types';
|
||||
import { api, configWithToken } from '~/utils/api';
|
||||
import { API } from '~/constants/api';
|
||||
|
||||
export const postUploadFile = ({
|
||||
access,
|
||||
file,
|
||||
target = 'others',
|
||||
type = 'image',
|
||||
}: {
|
||||
access: string;
|
||||
file: File;
|
||||
target: string;
|
||||
type: string;
|
||||
}): Promise<IResultWithStatus<IFile>> => {
|
||||
const data = new FormData();
|
||||
data.append('file', file);
|
||||
|
||||
return api.post(API.USER.UPLOAD(target, type), data, configWithToken(access));
|
||||
};
|
|
@ -1,4 +1,5 @@
|
|||
import { takeEvery, all, spawn, call, put, take, fork, race } from 'redux-saga/effects';
|
||||
import { postUploadFile } from './api';
|
||||
import { UPLOAD_ACTIONS } from '~/redux/uploads/constants';
|
||||
import {
|
||||
uploadUploadFiles, uploadSetStatus, uploadAddStatus, uploadDropStatus, uploadAddFile
|
||||
|
@ -9,8 +10,10 @@ import { HTTP_RESPONSES } from '~/utils/api';
|
|||
import { VALIDATORS } from '~/utils/validators';
|
||||
import { UUID, IFileWithUUID, IFile } from '../types';
|
||||
|
||||
|
||||
function* uploadCall({ temp_id, onProgress, file }) {
|
||||
return yield call(reqWrapper, fakeUploader, { file: { url: 'some', error: 'cant do this boss' }, onProgress, mustSucceed: true });
|
||||
// return yield call(reqWrapper, fakeUploader, { file: { url: 'some', error: 'cant do this boss' }, onProgress, mustSucceed: true });
|
||||
return yield call(reqWrapper, postUploadFile, { file: { url: 'some', error: 'cant do this boss' }, onProgress, mustSucceed: true });
|
||||
}
|
||||
|
||||
function* onUploadProgress(chan) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue