[69507b]: / app / frontend / src / actions / index.js

Download this file

28 lines (19 with data), 694 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import Images from '../api/images';
export const postRequest = (images) => async dispatch => {
var formData = new FormData();
var imageDict = {}
for (var i = 0; i < images.length; i++) {
let file = images.item(i);
formData.append('images[' + i + ']', file, file.name);
imageDict[file.name] = images.item(i)
}
const config = {
headers: { 'content-type': 'multipart/form-data' }
}
const response = await Images.post('/', formData, config)
dispatch({type:"POST_IMAGE",payload: response,images:imageDict})
}
export const removeData = () => {
console.log("removeData was called")
return({type:"REMOVE_DATA"})
}