django3.0使用通道和mongdob存储数据

时间:2020-02-24 15:29:11

标签: mongodb django-channels django-3.0

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
    }
});

0 个答案:

没有答案