django3.0使用通道和mongdob存储数据 我想为mongodb异步插入数据
export const uploadFiles = (files: File[], artworkId: string, fileType: string) => (
(dispatch: Dispatch) => {
files.forEach(file => {
axios.post(
`${my-api-route}, convertToFormDataFile(file, fileType))
.then(res => {
console.log(res.data.data.id) //works
dispatch(uploadFileLimitedEditionSuccess(res.data.data.id, file, fileType))
}) //does not work
.catch(err => dispatch(uploadFileLimitedEditionFailure(err.response.data.errors[fileType === 'pdf' ? 'pdf' : 'file'], file.name, fileType)))
})
}
);
引发错误
const uploadFileLimitedEditionSuccess = (id: any, file: File, fileType: string):LimitedEditionActionType => ({
type: LIMITED_EDITIONS_UPLOAD_FILE_SUCCESS,
payload: {
id,
file,
fileType
}
});