2.0.20 • Published 2 years ago

flow-helper v2.0.20

Weekly downloads
-
License
ISC
Repository
-
Last release
2 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

2 years ago

2.0.19

2 years ago

2.0.18

2 years ago

2.0.17

2 years ago

2.0.16

2 years ago

2.0.15

2 years ago

2.0.14

2 years ago

2.0.13

2 years ago

2.0.12

2 years ago

2.0.11

2 years ago

2.0.10

2 years ago

2.0.9

2 years ago

2.0.8

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago