---
title: xhrRequestOnError
slug: xhrrequestonerror
description: Learn how to handle errors in XHR requests with this helpful document. Discover a default function that takes XHR request, method used, URL, callback function, and callback arguments as parameters. Find out how to effectively log errors to the console usi
docTags: 
createdAt: 2022-05-04T10:13:11.000Z
---

This default consists of a function that is called when there is an error with an XHR request. It takes the XHR request, the method used, the URL, the callback, and the callback arguments as parameters. You can use this function to handle errors in your XHR requests.

For example, you could use this function to log the error to the console:

```javascript
HypeXAPI.setDefault('xhrRequestOnError', function(xhr, method, url, callback, callbackargs){
    console.log(xhr);
    console.log(method);
    console.log(url);
    console.log(callback);
    console.log(callbackargs);
});
```

