1

我是 Redux 和 Redux-Observable 的新手。我在使用 GET 和 GET(ID) 从 rest API 获取信息方面取得了成功,但我无法让 Delete 和 Post 工作。下面发出 GET 请求的示例代码:

[EPIC File]
import { debounceTime, Observable } from 'rxjs';
import { ajax } from 'rxjs/observable/dom/ajax';
import ActionTypes from '../actions/ActionTypes';
import { receiveFeedBack, receiveDeleteFeedBackId,
receiveFeedBackId } from '../actions/FeedBackActions';


export const fetchFeedBack = (action$) =>      ... Working
export const fetchFeedBackId  = (action$) =>   ... Working

//Not Working
export const deleteFeedBackById = (action$) =>
  action$.ofType(ActionTypes.DELETE_FEEDBACK_REQUEST)
  .debounceTime(500)
  .switchMap(action =>
    ajax.delete(`${ActionTypes
      .FEEDBACK__URL}/posts/${action.payload.feedbackId}?key=${ActionTypes
      .FEEDBACK__API_KEY}`)
      .map(receiveDeleteFeedBackId.bind(action))
      .takeUntil(action$.ofType(ActionTypes.DELETE_FEEDBACK_CANCELED))
      .catch(error => Observable.of({
        type: ActionTypes.DELETE_FEEDBACK_ERROR,
        payload: error
      }))
);

我究竟做错了什么?

4

0 回答 0