typesafe-actions(createStandardAction) not working on server with redux

Viewed 546

I'm trying to dispatch an action which is by using createStandardAction(typesafe-actions) and then it goes to epic(redux-observable) for api call. The strange part is that it works perfectly with stub data, it completes the flow(i.e., component->action->epic->reducer->store) but the action doesn't trigger or enters the epic while using it with the actual server

**Component:-**
    export const mapDispatchToProps = (dispatch: Dispatch): ReduxActions => ({
      loadTestData: () => dispatch(loadTestData())
    })
    export default connect(
      mapStateToProps,
      mapDispatchToProps
    )(withNavigation(loadData))

**Action**
    import { ActionsUnion, createStandardAction } from 'typesafe-actions'
    export const LOADDATA_GET = 'LOADDATA_GET'

    export const loadData = createStandardAction(LOADDATA_GET)<void>()

    const actions = {
      loadData
    }

    export type AllActions = ActionsUnion<typeof actions>

**Epic**
    import { Action, MiddlewareAPI } from 'redux'
    import { ActionsObservable, Epic } from 'redux-observable'
    import { Observable } from 'rxjs'
    import {
      LOADDATA_GET
    } from './loadData.actions'

    export const getloadDataEpic: Epic<Action, ReduxState> = (
      action$: ActionsObservable<any>,
      store: MiddlewareAPI<any, ReduxState>,
      { mobileAPI }: EpicDependencies
    ) =>
      action$
        .ofType(LOADDATA_GET)
        .mergeMap((action) => {
          return Observable.merge(
            mobileAPI
              .getJSON('/dummypath/loadData')
              .mergeMap((response) => {
                return Observable.of<any>(
                  setLoadData(response)
                )
              })
          )}
        )
        .catch((error) => {
          return Observable.of(errorAction(error))
        })

I am really confused why the flow doesn't comes to epic for the actual server while for local json data and dummy path it works

1 Answers

Issue fixed, there was some data-mapping issue on the server side

Related