fix: #355 [Bug] [Browser] responseType "json" not working with valid JSON response

This commit is contained in:
Sefa Ilkimen
2020-08-18 02:16:03 +02:00
parent 9bb0c58e35
commit 1639efe8d0
2 changed files with 14 additions and 12 deletions
+1
View File
@@ -3,6 +3,7 @@
## 3.0.1
- Fixed #359: memory leakage leads to app crashes on Android
- Fixed #355: responseType "json" not working with valid JSON response on browser (thanks millerg6711)
## 3.0.0
+6 -5
View File
@@ -38,11 +38,11 @@ function serializeParams(params) {
}
function decodeB64(dataString) {
var binarString = atob(dataString);
var bytes = new Uint8Array(binarString.length);
var binaryString = atob(dataString);
var bytes = new Uint8Array(binaryString.length);
for (var i = 0; i < binarString.length; ++i) {
bytes[i] = binarString.charCodeAt(i);
for (var i = 0; i < binaryString.length; ++i) {
bytes[i] = binaryString.charCodeAt(i);
}
return bytes.buffer;
@@ -212,8 +212,9 @@ function sendRequest(method, withData, opts, success, failure) {
break;
}
// requesting text instead of JSON because it's parsed in the response handler
xhr.responseType = responseType === 'json' ? 'text' : responseType;
xhr.timeout = timeout * 1000;
xhr.responseType = responseType;
setHeaders(xhr, headers);
xhr.onerror = function () {