Skip to content

Commit 4804d0b

Browse files
committed
handle json case and also handle both ArrayBuffer and Buffer passed by 'data' callback equally
1 parent 3fd4eee commit 4804d0b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,12 @@ NodeHttpXHR.prototype = Object.create(
316316
case 'text':
317317
return this._responseText;
318318
case 'arraybuffer':
319-
return this._response;
319+
case 'json':
320+
if (this._response instanceof ArrayBuffer) {
321+
return this._response;
322+
} else if (this._response instanceof Buffer) {
323+
return this._response.buffer;
324+
}
320325
default:
321326
throw new Error('Assertion failed: unsupported response-type: ' + type);
322327
}

0 commit comments

Comments
 (0)