Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiClientMiddleware broken? Cannot read property 'request' of undefined #101

Open
Slodin opened this issue Apr 19, 2019 · 0 comments
Open

Comments

@Slodin
Copy link

Slodin commented Apr 19, 2019

My code works with axiosMiddleware, but after I switched over to multiclent, everything went wrong. It keep on giving me

Cannot read property 'request' of undefined

It seems like it's not getting the request from the redux action in payload.

import {multiClientMiddleware} from 'redux-axios-middleware';

export default ReduxStore = createStore(
    rootReducer, 
    applyMiddleware(
        multiClientMiddleware(
            AxiosClient
        )
    )
)

AxiosClient = {
    default: {
      client: axios.create({
        baseURL: baseUrl,
        timeout: 6000,
        responseType: 'json',
      })
      options: defaultConfig
    },
    googleMaps: {
      client: axios.create({
        baseURL: baseGoogleMapAPI,
        timeout: 6000,
        responseType: 'json'
      })
    }
  }

const defaultConfig = {
  interceptors: {
    request: [{
      success: function ({getState, dispatch, getSourceAction}, req) {
        handleTokenAuth(req);
      },
      error: function ({getState, dispatch, getSourceAction}, error) {
        Promise.reject(error)
      }
    }
    ],
    response: [{
      success: function ({getState, dispatch, getSourceAction}, req) {
        handleAxiosSuccess(req);
      },
      error: function ({getState, dispatch, getSourceAction}, error) {
        handleAxiosError(error);
      }
    }
    ]
  }
}

Redux action, it pretty much dies here

export function getUser(){
    return {
        type: "GET_USER",
        payload: {
            client: 'default',
            request: {
                method: 'GET',
                url: '/auth/user'
            }
        }
    };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant