renamed param serializer to data serializer

This commit is contained in:
Sefa Ilkimen
2016-11-14 00:47:24 +01:00
parent 050ed894d6
commit 0989de20ab
2 changed files with 13 additions and 13 deletions
+6 -6
View File
@@ -53,14 +53,14 @@ Set a header for all future requests. Takes a header and a value.
cordovaHTTP.setHeader("Header", "Value");
### setParamSerializer
Set the parameter serializer which will be used for all future POST and PUT requests. Takes a string representing the name of the serializer.
### setDataSerializer
Set the data serializer which will be used for all future POST and PUT requests. Takes a string representing the name of the serializer.
cordovaHTTP.setParamSerializer("urlencoded");
cordovaHTTP.setDataSerializer("urlencoded");
You can choose one of these two:
* `urlencoded`: send parameters as url encoded content in body (content type "application/x-www-form-urlencoded")
* `json`: send parameters as JSON encoded content in body (content type "application/json")
* `urlencoded`: send data as url encoded content in body (content type "application/x-www-form-urlencoded")
* `json`: send data as JSON encoded content in body (content type "application/json")
## Async Functions
These functions all take success and error callbacks as their last 2 arguments.
@@ -97,7 +97,7 @@ Whether or not to validate the domain name in the certificate. This defaults to
});
### post<a name="post"></a>
Execute a POST request. Takes a URL, parameters, and headers.
Execute a POST request. Takes a URL, data, and headers.
#### success
The success function receives a response object with 3 properties: status, data, and headers. Status is the HTTP response code. Data is the response from the server as a string. Headers is an object with the headers. Here's a quick example:
+7 -7
View File
@@ -64,7 +64,7 @@ function checkSerializer(serializer) {
var http = {
headers: {},
paramSerializer: 'urlencoded',
dataSerializer: 'urlencoded',
sslPinning: false,
getBasicAuthHeader: function (username, password) {
return {'Authorization': 'Basic ' + b64EncodeUnicode(username + ':' + password)};
@@ -75,8 +75,8 @@ var http = {
setHeader: function (header, value) {
this.headers[header] = value;
},
setParamSerializer: function (serializer) {
this.paramSerializer = checkSerializer(serializer);
setDataSerializer: function (serializer) {
this.dataSerializer = checkSerializer(serializer);
},
enableSSLPinning: function (enable, success, failure) {
return exec(success, failure, 'CordovaHttpPlugin', 'enableSSLPinning', [enable]);
@@ -91,7 +91,7 @@ var http = {
data = data || {};
headers = headers || {};
headers = mergeHeaders(this.headers, headers);
return exec(success, failure, 'CordovaHttpPlugin', 'post', [url, data, this.paramSerializer, headers]);
return exec(success, failure, 'CordovaHttpPlugin', 'post', [url, data, this.dataSerializer, headers]);
},
get: function (url, params, headers, success, failure) {
params = params || {};
@@ -103,13 +103,13 @@ var http = {
data = data || {};
headers = headers || {};
headers = mergeHeaders(this.headers, headers);
return exec(success, failure, 'CordovaHttpPlugin', 'post', [url, data, this.paramSerializer, headers]);
return exec(success, failure, 'CordovaHttpPlugin', 'post', [url, data, this.dataSerializer, headers]);
},
delete: function (url, params, headers, success, failure) {
params = params || {};
headers = headers || {};
headers = mergeHeaders(this.headers, headers);
return exec(success, failure, 'CordovaHttpPlugin', 'post', [url, params, this.paramSerializer, headers]);
return exec(success, failure, 'CordovaHttpPlugin', 'post', [url, params, this.dataSerializer, headers]);
},
head: function (url, params, headers, success, failure) {
headers = mergeHeaders(this.headers, headers);
@@ -178,7 +178,7 @@ if (typeof angular !== 'undefined') {
setHeader: function (header, value) {
return http.setHeader(header, value);
},
setParamSerializer: function (serializer) {
setDataSerializer: function (serializer) {
return http.setParamSerializer(serializer);
},
enableSSLPinning: function (enable) {