使用Axios成功时,函数参数未定义

时间:2017-01-31 15:47:28

标签: javascript reactjs redux react-redux axios

我正在使用reducer上定义的属性从componentDidMount调用一个动作。在fetchAppClasses操作中,我正在使用axios库进行获取,并且在成功中我需要该属性“选择”但在那里是未定义的。

这里的行动:

//selection is defined here
       export function fetchAppClasses(selection) {
          return function (dispatch) {
            var axcfg = { headers: { 'X-Auth-Token': window[config.storageType].token } };
            return axios.get(config.apiUrl + '/sdwan/appClasses', axcfg)
              .then(function (response) {
//selection in undefined here
                console.log('SDWanActions.fetchAppClasses response:', response);
                dispatch(fetchAppClassesSuccess(response.data));
              })      
          }
        }

0 个答案:

没有答案