Simple Promise wrapper for XHR
Options:
- method : GET | POST | ...
- data : post body
- form : form element to POST
- headers: {}
- query:
If form is provided, it will override data, and a FormData instance will be constructed with it.
If provided, data will be encoded according to the 'Content-Type' header. If it is 'application/json', then data will be JSON encoded. Otherwise, URL encoding will be applied.
Any values added to this Object will be set as Headers on all requests.
A hook to allow a callable to inspect and modify headers before each request.
Automatically decodes successful responses from JSON.
Sets 'Content-Type' as 'application/json', passes method in a 'X-RPC-Action' header, and JSON decodes the response.
All errors are raised using this class.
Properties:
- message: the Method and URL of the request
- errorType: one of 'error', 'timeout', or 'abort'
- xhr : the XMLHttpRequest instance