Skip to content

Instantly share code, notes, and snippets.

@Prasanna-Poonacha
Last active November 2, 2020 11:17
Show Gist options
  • Save Prasanna-Poonacha/524946ca4038c1db1064461dfaef1e19 to your computer and use it in GitHub Desktop.
Save Prasanna-Poonacha/524946ca4038c1db1064461dfaef1e19 to your computer and use it in GitHub Desktop.
HTTP
function easyHttp() {
this.http = new XMLHttpRequest();
}
easyHttp.prototype.get = function (url, cb) {
let self = this;
self.http.open('GET', url, true);
self.http.onload = function () {
if (self.http.status === 200) {
return cb(null, self.http.responseText);
} else {
return cb('Status ' + self.http.status);
}
};
self.http.send();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment