'Not able to see exact error message at Redux

I have the almost same issue that asked before

I have tried to use the same solution but could not manage it.

enter image description here

All I want to see is to get correct error message. And I have written this part.

export const createNewC = createAsyncThunk(
  'c/',
  async (input: c, { rejectWithValue }) => {
    try {
      return (await companiesService.create(input)) as c;
    } catch (error) {
      console.log('here');
      const response = (error as AxiosError).response as AxiosResponse;
      console.log('here2', response.data);
      let errorMessage = '';
      errorMessage = response.data.message;
      console.log('here3');
      console.log(errorMessage, 'mess36 ');
      const latest = rejectWithValue(apiErrorMessageToTranslationKey(errorMessage));
      return latest;
    }
  },
);

As you may notice, the second console log which is "here2, response.data" is not visible to me.

What I am doing wrong?



Solution 1:[1]

Since the line where you are trying to access error.response.data does not log any more, I would assume error.response is undefined and your error handler crashes.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 phry