Skip to content

@kriskowal /q-xhr.js
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
var Q = require("q");
exports.read = function (path, timeout) {
var response = Q.defer();
var request = new XMLHttpRequest(); // ActiveX blah blah
request.open("GET", path, true);
request.onreadystatechange = function () {
if (request.readyState === 4) {
if (request.status === 200) {
response.resolve(request.responseText);
} else {
response.reject("HTTP " + request.status + " for " + path);
}
}
};
timeout && setTimeout(response.reject, timeout);
request.send('');
return response.promise;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.