Created
September 28, 2019 14:45
-
-
Save nkint/823a4d308eee300c272a32f4213bb59e to your computer and use it in GitHub Desktop.
Load array buffer via XMLHttpRequest, the old good way
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
function ab2str(buf: any) { | |
return Buffer.from(buf).toString("utf8"); | |
} | |
console.log("hello"); | |
var oReq = new XMLHttpRequest(); | |
console.log(oReq); | |
oReq.addEventListener("load", reqListener); | |
oReq.open("GET", "./test.env"); | |
oReq.responseType = "arraybuffer"; | |
oReq.send(); | |
function reqListener(responseText: any) { | |
console.log("load", responseText); | |
console.log("array buffer:", ab2str(oReq.response), "."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment