Redux Action возвращает неопределенную проблему и проблему с прокси-узлом в ReactionJS - PullRequest
0 голосов
/ 08 ноября 2018
Error I get Given action "DID_FETCH_SUCCESS", reducer "did" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.

**My Action Class:**


/**
 * DID Search in progress.
 */
 export const didSearchIsLoading = isLoading => {
   return {
     type: DID_SEARCH_IS_LOADING,
     payload: isLoading
   }
};

/**
 * DID Search error.
 */
export const didSearchError = error => {
  return {
    type: DID_SEARCH_ERROR,
    payload: error
  }
};

/**
 * Payload is a list of DID's.
 */
 export const didSearchSuccess = (country, result) => {
   return {
     type: DID_SEARCH_SUCCESS,
     payload: {
       country,
       result
     }
   }
};

/**
 * Performs API call to search for DID's matching query params.
 */
 export const didSearchFetchData = (country, criteria) => {
   return (dispatch) => {
     dispatch(didSearchIsLoading(true));

     postDIDSearch(country, criteria)
     .then((data) => {
       dispatch(didSearchIsLoading(false));
       console.log('data',data)
       // If only one result
       if (data.dids.length == 1) {
          dispatch(didFetchSuccess(data.dids[0][country.toLowerCase()]))
          dispatch(push(`/console/did/${country}/${data.dids[0][country.toLowerCase()].e164}`));
       } else {
         dispatch(push('/console/did/search/result'));
         dispatch(didSearchSuccess(country, data));
       }
     })
     .catch(error => {
       dispatch(didSearchIsLoading(false));
       dispatch(didSearchError(error.message));
     })
   }
};


/*********************** DID-specific Action Creators *************************/
/**
 * Fetching of a specific DID/E164 in progress.
 */
 export const didIsLoading = isLoading => {
   return {
     type: DID_IS_LOADING,
     payload: isLoading
   }
};

/**
 * Successful fetch of DID/E164.
 * Payload is the DID.
 */
 export const didFetchSuccess = did => {
   console.log('did',did);
  return {
    type: DID_FETCH_SUCCESS,
    payload: did
  }
};

/**
 * Fetching error for a specific DID/E164.
 */
export const didFetchError = error => {
  return {
    type: DID_FETCH_ERROR,
    payload: error
  }
};


**My Reducer:**

import {DID_SEARCH_IS_LOADING, DID_SEARCH_ERROR, DID_SEARCH_SUCCESS,
DID_IS_LOADING, DID_IS_UPDATING, DID_FETCH_ERROR, DID_FETCH_SUCCESS, DID_UPDATE_ERROR,
DID_UPDATE_SUCCESS}
from '../actions/did.action';

export const searchIsLoading = (state = false, action) => {
  switch (action.type) {
    case DID_SEARCH_IS_LOADING:
      return action.payload
    default:
      return state
  }
}

export const searchSuccess = (state = {}, action) => {
  switch (action.type) {
    case DID_SEARCH_SUCCESS:
      return action.payload
    default:
      return state
  }
}

export const searchError = (state = null, action) => {
  switch (action.type) {
    case DID_SEARCH_ERROR:
      return action.payload
    default:
      return state
  }
}

export const didIsLoading = (state = false, action) => {
  switch (action.type) {
    case DID_IS_LOADING:
      return action.payload
    default:
      return state
  }
}

export const didIsUpdating = (state = false, action) => {
  switch (action.type) {
    case DID_IS_UPDATING:
      return action.payload
    default:
      return state
  }
}

export const didFetchError = (state = null, action) => {
  switch (action.type) {
    case DID_FETCH_ERROR:
      return action.payload
    default:
      return state
  }
}

export const didFetchSuccess = (state = {}, action) => {
  console.log('redstate',state);
  console.log('redpayload',action.payload);
  switch (action.type) {
    case DID_FETCH_SUCCESS:
      return action.payload
    default:
      return state
  }
}

export const didUpdateSuccess = (state = null, action) => {
  switch (action.type) {
    case DID_UPDATE_SUCCESS:
      return action.payload
    default:
      return state
  }
}

export const didUpdateError = (state = null, action) => {
  switch (action.type) {
    case DID_UPDATE_ERROR:
      return action.payload
    default:
      return state
  }
}

В последнее время я столкнулся с двумя проблемами.1. Я пытаюсь получить числа, но он возвращает неопределенную ошибку.Undefined возвращается в didFetchSuccess, когда я пытаюсь его отладить.До этого момента в нем есть данные.2. Когда я пытаюсь выполнить какой-либо поиск и если ответ большой, он выдает ошибку прокси-сервера, например, невозможность прокси, от http://localhost:3000 до http://localhost:8002. Ошибка ECONNRESET на узле.

У меня уже есть правильно заданные маршруты и прокси.

Ошибка прокси: Не удалось запросить прокси / ossapi / v1 / number / US? Search_availableonly = false & search_npanxx = 205_201 от localhost: 3000 до http://localhost:8002. См. https://nodejs.org/api/errors.html#errors_common_system_errors для получения дополнительной информации (ECONNRESET).

...