Proper Use of Redux-Ovservable ajax http methods: put, delete, post

核能气质少年 提交于 2019-12-11 05:14:50

问题


I'm new to Redux and Redux-Observable. I'm having success in getting information from a rest API with GET and GET(ID), but I cannot get the Delete and Post to work. Sample code below that is issuing a GET request:

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

What am I doing wrong?

来源:https://stackoverflow.com/questions/40708264/proper-use-of-redux-ovservable-ajax-http-methods-put-delete-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!