- update readme

- implement response type support for browser platform
This commit is contained in:
Sefa Ilkimen
2019-06-14 00:52:27 +02:00
parent 85346e0381
commit 1fc3d6230c
2 changed files with 8 additions and 1 deletions
+3
View File
@@ -202,6 +202,9 @@ The options object contains following keys:
* `data`: payload to be send to the server (only applicable on `post`, `put` or `patch` methods)
* `params`: query params to be appended to the URL (only applicable on `get`, `head`, `delete`, `upload` or `download` methods)
* `serializer`: data serializer to be used (only applicable on `post`, `put` or `patch` methods), defaults to global serializer value, see [setDataSerializer](#setDataSerializer) for supported values
* `responseType`: expected response type, defaults to `text`, needs to be one of the following values:
* `text` use this for all kind of text responses (e.g. JSON, XML, HTML, plain text, etc.)
* `arraybuffer` use this one for binary responses
* `timeout`: timeout value for the request in seconds, defaults to global timeout value
* `followRedirect`: enable or disable automatically following redirects
* `headers`: headers object (key value pair), will be merged with global values
+5 -1
View File
@@ -101,7 +101,7 @@ function setHeaders(xhr, headers) {
}
function sendRequest(method, withData, opts, success, failure) {
var data, serializer, headers, timeout, followRedirect;
var data, serializer, headers, timeout, followRedirect, responseType;
var url = opts[0];
if (withData) {
@@ -110,10 +110,13 @@ function sendRequest(method, withData, opts, success, failure) {
headers = opts[3];
timeout = opts[4];
followRedirect = opts[5];
responseType = opts[6];
} else {
headers = opts[1];
timeout = opts[2];
followRedirect = opts[3];
responseType = opts[4];
}
var processedData = null;
@@ -152,6 +155,7 @@ function sendRequest(method, withData, opts, success, failure) {
}
xhr.timeout = timeout * 1000;
xhr.responseType = responseType;
setHeaders(xhr, headers);
xhr.onerror = xhr.ontimeout = function () {