Search code examples
javascriptreactjsreact-nativereact-reduxredux-observable

How to make PUT and DELETE on redux-observable


I'm able to do GET and POST call using redux-observable but not sure how to do PUT and DELETE with it, please find below my sample code, with syntax for GET and POST(commented)

export const testEpic: Epic<Action, ReduxState> = (
  action$: ActionsObservable<any>,
  store: MiddlewareAPI<any, ReduxState>,
  { testAPI }: EpicDependencies
) =>
  action$
    .ofType(TEST_GET)
    .mergeMap((action) => {
      return Observable.merge(
        testAPI
          .getJSON('/path/test-data')
           //.postJSON(/path/test-post, payload)
          .mergeMap((response) => {
            // Code
          })
      )
    }
    )
    .catch((error) => {
      return Observable.of(errorAction(error))
    })

Solution

  • I fixed it, it's by using simple PUT and DELETE only, but in a different way as per my project configuration