# Event handler

## How catch api error

When axios interceptor catch error api fired [customEvent](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent) with _'apiErrorEvent'_ name.

{% hint style="info" %}
&#x20;Event value contains in .detail field.
{% endhint %}

### Example:

{% code title="Field error contains in JSON Api sceme or default response" %}
```javascript
window.addEventListener(
    'apiErrorEvent',
    evt => {
        console.log(evt.detail.errors);
    },
    false
);

```
{% endcode %}

