Last active
January 26, 2017 03:51
-
-
Save scottshane/0a7c6030a434fdb4d8cbb13cc84e30dc to your computer and use it in GitHub Desktop.
tiny xhr constructor
This file contains hidden or 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
const xhr = new window['XMLHttpRequest' || 'ActiveXObject']('MSXML2.XMLHTTP.3.0'); | |
let res; | |
xhr.open('GET', 'some/api/endpoint'); | |
xhr.responseType = 'json'; | |
xhr.onreadystatechange = function () { | |
if (this.status === 200 && this.readyState === 4) { | |
resp = this.response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment