2.0.20 • Published 3 years ago

flow-helper v2.0.20

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

error-helper

To start using:

yarn add @axmit/error-helper
import { errorMapper } from '@axmit/error-helper';

axios.interceptors.response.use(
  response => response.data,
  error => errorMapper
);
If you want show popup
import { errorMapper } from '@axmit/error-helper';
import { message } from 'antd';

...

axios.interceptors.response.use(
  response => response.data,
  error => errorMapper(error, { showError: message.error, defaultError: 'An error occurred, please try again later' })
);
Examples for different params
axios.interceptors.response.use(
  response => response.data,
  error => {
    const popupConfig = { showError: message.error, defaultError: EBaseErrorMessage.Default };
    const codesConfig = {
      withValidations: [...defaultCodesWithValidations, EErrorStatus.RetryWith],
      withPopupMessage: [EErrorStatus.PayloadTooLarge]
    };

    return errorMapper(error, popupConfig, codesConfig, t);
  }
);
Examples with antd4 forms (where error has type IError)
const LoginFormComponent: React.FC<AllProps> = props => {
    const { customerModel } = props;
    const { errors, params, data } = customerModel;
    const { fields } = useFormMapper(['name', 'email', 'password'], data, params, errors);
    ...

    return (
        <Form onFinish={login} fields={fields}>
2.0.20

3 years ago

2.0.19

3 years ago

2.0.18

3 years ago

2.0.17

3 years ago

2.0.16

3 years ago

2.0.15

3 years ago

2.0.14

3 years ago

2.0.13

3 years ago

2.0.12

3 years ago

2.0.11

3 years ago

2.0.10

3 years ago

2.0.9

3 years ago

2.0.8

3 years ago

2.0.7

3 years ago

2.0.6

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago