在React Redux中使用.map链接异步axios调用

时间:2018-11-13 22:01:25

标签: reactjs redux axios redux-thunk

所以我试图发布一系列图像,但是我只希望地图在上一个调用完成后才能前进。我的单数postImage(id, file)调用是异步axios调用,它使用.then。是否缺少我缺少的简单React函数或一些有用的JS工具?

export const postAllImages = (id, fileList) => dispatch => {
  dispatch({
    type: str.START_LOADING,
    payload: 'Loading...'
  })
  _.map(fileList, file => {
    postImage(id, file)
  })
  dispatch({
    type: str.POST_ALL_IMAGES
  })
  dispatch({
    type: str.FINISH_LOADING
  })
}

谢谢你!

0 个答案:

没有答案
相关问题