The code works but I'm wondering if I'm over promising.
I have this Redux Action
import Promise from 'bluebird';
const uploadAsynch = Promise.promisify(api.upload);
uploadFiles : function(data, dispatch){
var data = {
ep:"EP_UPLOAD",
payload: {
files: data.files,
profile: data.profile
}
}
uploadAsynch(data).then((result)=>{
dispatch({type: FILES_UPLOADED})
});
},
api.upload is the following
import axios from 'axios';
upload : function(data, callback){
var files = new FormData();
for(var i=0; i<data.payload.files.length; i++){
files.append('files', data.payload.files[i], data.payload.files[i].name);
}
axios.post(apiEndpoints[data.ep], files, {
headers: {
'accept': 'application/json',
'Accept-Language': 'en-US,en;q=0.8',
'Content-Type': `multipart/form-data; boundary=--*`,
}
})
.then((response) => {
callback(null, response)
}).catch((error) => {
callback(error)
});
},
So I'm wondering. If Axios is a promise based request client is it correct to wrap it with bluebird in the action?