这就是我所拥有的......但我怀疑这是否合法。 基本上我想要实现的是我获取一个项目,如果它失败了,我想发一个帖子请求。
try {
const response = yield call(axios.get, `/api/cars/${action.payload.car}`)
yield put({type: RECEIVE_CAR, requestPending : false, data: response.data})
} catch (e) {
console.log(e)
try {
const response = yield call(axios.post, `/api/cars/`, action.payload)
yield put({type: RECEIVE_CAR, requestPending : false, data: response.data})
} catch (error) {
console.log(error)
}
}