Last active
November 2, 2020 11:17
-
-
Save Prasanna-Poonacha/524946ca4038c1db1064461dfaef1e19 to your computer and use it in GitHub Desktop.
HTTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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