API response on Upload
setting state based on the API response. They're meant to represent how the frontend will show the user that the uploads are pending/successful/failed. To implement this, the dispatch part of the function needs to be set up as a Promise, to .then have effects based on the response of the action.
The pending list should really only be cleared once the API confirms they have been uploaded. Otherwise, the user will always lose their data regardless of whether the upload was *successful).
Can use RequestError class?
Old code - was wrong
// if receive 200 OK status:
// clear uploadList
this.props.dispatch(updateUploadList({
files: [],
journalEntries: []
}));
this.setState({
successMessage: 'Your files have been uploaded to Mahara'
})
// // if receive !200:
this.setState({
successMessage: 'It appears that you are offline or some other error has occurred. Please try again later.'
});
Edited by Kristina Hoeppner