Package Exports
- xhr
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (xhr) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
xhr
A small xhr wrapper
Example
var xhr = require("xhr")
xhr({
method: "GET",
data: someJSON,
uri: "/foo",
headers: {
"Content-Type": "application/json"
}
}, function (err, result) {
// this === xhr
})var req = xhr(options, callback)
the returned object is either an XMLHttpRequest instance
or an XDomainRequest instance (if on IE8/IE9)
Your callback will be called once with either an Error
or a valid result. The result will be either
xhr.response, xhr.responseText or
xhr.responseXML depending on the request type.
Your callback will be called with an Error if the
resulting status of the request is either 0, 4xx or 5xx
options.method
Specify the method the XMLHttpRequest should be opened
with. Passed to xhr.open
options.data
Pass in data to be send across the XMLHttpRequest.
Generally should be a string. But anything that's valid as
a parameter to xhr.send should work
options.status
Set this to false if you do not want this module to turn
a status code of 4xx, 5xx or 0 into an error.
options.uri
The uri to send a request too. Passed to
xhr.open
options.headers
An object of headers that should be set on the request. The
key, value pair is passed to xhr.setRequestHeader