Get the answer from the server as blob or arraybuffer
-
How to get an answer from the server as a facility
Blob
orArrayBuffer
? I do that.var xhr = new XMLHttpRequest(); xhr.open("GET", "/sample.blob"); xhr.responseType = "blob"; xhr.send(); xhr.onload = (e) => { console.log(e.loaded); var buf = xhr.respose; var reader = new FileReader(); reader.readAsArrayBuffer(buf); // тут ошибка reader.onload = () => {/* ... */ }; }
Makes a mistake -
buf
not subjectblob
♪ How do you interpret the answer a double file?
-
Comments on corrections in the code:
var xhr = new XMLHttpRequest(); xhr.open("GET", "/sample.blob"); xhr.responseType = "blob"; xhr.onload = (e) => { console.log(e.loaded); var buf = xhr.response; // здесь была опечатка } xhr.send(); // это в конец
See details. https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data ♪