xhr.response is undefined on blob/arraybuffer response type
See original GitHub issueTrying to get this file with your nodejs xmlhttprequest
$ curl -X GET -I http://localhost/test/foo.bin
HTTP/1.1 200 OK
Date: Wed, 20 Jun 2018 11:58:51 GMT
Server: Apache/2.4.33 (Unix)
Last-Modified: Tue, 19 Jun 2018 18:37:07 GMT
ETag: "6-56f02f8230618"
Accept-Ranges: bytes
Content-Length: 6
Content-Type: application/octet-stream
using the following code:
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var xhr = new XMLHttpRequest;
xhr.open("GET", "http://localhost/test/foo.bin");
xhr.setRequestHeader("Accept", "application/octet-stream");
xhr.responseType = "blob";
xhr.onreadystatechange = function(e) {
if (xhr.readyState == 4) {
console.log(xhr.response);
console.log(xhr.responseText);
}
};
xhr.send();
Result is undefined
for the logline with xhr.response
and correct value in xhr.responseText
.
Does your module only work for text?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:5
- Comments:6
Top Results From Across the Web
Getting BLOB data from XHR request - Stack Overflow
responseType = 'arraybuffer'; // Process the response when the request is ready. xhr.onload = function(e) { if (this.status == 200) ...
Read more >this.response is undefined when responseType is a Blob ...
Hi I've tested this plugin in my case, a file object with a file url (from upload) and creating a Blob file of...
Read more >XMLHttpRequest.responseType - Web APIs | MDN
The XMLHttpRequest property responseType is an enumerated string value specifying the type of data contained in the response.
Read more >fetch() - The Vanilla JS Toolkit
'undefined' ? factory(exports) : typeof define === 'function' && define.amd ... _bodyBlob.type) { this.headers.set('content-type', this._bodyBlob.type); } ...
Read more >XMLHttpRequest JavaScript API - JavaScripture
responseType = 'arraybuffer'; request.open('GET', '/'); request.onload = function() { console.log(request.response); console.log(request.response.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @nolash I met the same problem here, do you have any work around now?
i’m just using the node library for file reads now