diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-05-29 02:44:25 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-05-29 02:44:25 +0200 |
| commit | f5c04fc92a4e23948b477f4f579b953e8edd6bb2 (patch) | |
| tree | 2a7de103dfde225b6ba90f70ba20d8b1c1d951bc /app/client/api/crud.upload.js | |
| parent | b0440c213ac9f97e558b3d15d3740dab234b7b79 (diff) | |
omg making an api request
Diffstat (limited to 'app/client/api/crud.upload.js')
| -rw-r--r-- | app/client/api/crud.upload.js | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/app/client/api/crud.upload.js b/app/client/api/crud.upload.js index 26917ff..f680a74 100644 --- a/app/client/api/crud.upload.js +++ b/app/client/api/crud.upload.js @@ -1,6 +1,6 @@ import { as_type } from './crud.types' -export function crud_upload(type, id, fd, dispatch) => { +export function crud_upload(type, id, fd, dispatch) { return new Promise( (resolve, reject) => { const xhr = new XMLHttpRequest() xhr.upload.addEventListener("progress", uploadProgress, false) @@ -42,7 +42,7 @@ export function crud_upload(type, id, fd, dispatch) => { } dispatch && dispatch({ type: as_type(type, 'upload_complete'), - data + data, [type]: id, }) } @@ -58,13 +58,11 @@ export function crud_upload(type, id, fd, dispatch) => { uploadCancelled = function (evt) { dispatch && dispatch({ type: as_type(type, 'upload_error'), - error: 'upload cancelled' + error: 'upload cancelled', [type]: id, }) } }) } -export function uploadAction(type, id, fd) { - return dispatch => crud_upload(type, id, fd, dispatch) -}
\ No newline at end of file +export const upload_action = (type, id, fd) => dispatch => crud_upload(type, id, fd, dispatch) |
