From f5c04fc92a4e23948b477f4f579b953e8edd6bb2 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 29 May 2018 02:44:25 +0200 Subject: omg making an api request --- app/client/api/crud.upload.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'app/client/api/crud.upload.js') 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) -- cgit v1.2.3-70-g09d2