diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/client/api/crud.actions.js | 8 | ||||
| -rw-r--r-- | app/client/api/index.js | 23 |
2 files changed, 15 insertions, 16 deletions
diff --git a/app/client/api/crud.actions.js b/app/client/api/crud.actions.js index 10abbba..59d4d82 100644 --- a/app/client/api/crud.actions.js +++ b/app/client/api/crud.actions.js @@ -16,7 +16,13 @@ so you can do ... export function crud_actions(type) { const fetch_type = crud_fetch(type) - return ['index', 'show', 'create', 'update', 'destroy'].reduce((lookup, param) => { + return [ + 'index', + 'show', + 'create', + 'update', + 'destroy' + ].reduce((lookup, param) => { lookup[param] = crud_action(type, param, () => fetch_type[type](param)]), return lookup }, { diff --git a/app/client/api/index.js b/app/client/api/index.js index 8db9c23..4e894e2 100644 --- a/app/client/api/index.js +++ b/app/client/api/index.js @@ -1,19 +1,12 @@ import FormData from 'form-data' import fetch from 'node-fetch' -import { crud_fetch, postBody } from './crud.fetch' +import { crud_actions } from './crud.actions' -export const folder = crud_fetch('folder') -export const file = crud_fetch('file') -export const dataset = crud_fetch('dataset') -export const task = crud_fetch('task') - -// folder.upload = (folder_id, files) => { -// var data = new FormData() -// for (var i = 0; i < files.length; i++) { -// data.append('file', files[i]) -// } -// return fetch('/api/folders/' + folder_id, postBody(data)) -// .then(req => req.json()) -// .catch(error) -// } +export default [ + 'folder', + 'file', + 'dataset', + 'task', + 'user', +].reduce((a,b) => (a[b]=crud_actions(b))&&a, {}) |
