Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
remove __fh from body/query for non-jsonp requests (issue #149) (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanshortiss authored Sep 9, 2016
1 parent 1c268dd commit 6827e03
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
12 changes: 10 additions & 2 deletions src/modules/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var ajax = module.exports = function (options) {

if (!settings.crossDomain) {
settings.crossDomain = /^([\w-]+:)?\/\/([^\/]+)/.test(settings.url) && (RegExp.$1 != window.location.protocol || RegExp.$2 != window.location.host)
}
}

var dataType = settings.dataType,
hasPlaceholder = /=\?/.test(settings.url)
Expand Down Expand Up @@ -98,7 +98,15 @@ var ajax = module.exports = function (options) {
logger.debug("retry ajax call with jsonp")
settings.type = "GET";
settings.dataType = "jsonp";
settings.data = "_jsonpdata=" + settings.data;

if (settings.data) {
settings.data = "_jsonpdata=" + JSON.stringify(
require("./fhparams").addFHParams(JSON.parse(settings.data))
);
} else {
settings.data = "_jsonpdata=" + settings.data;
}

return ajax(settings);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/modules/api_act.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ function doActCall(opts, success, fail){
var cloud_host = cloud.getCloudHost();
var url = cloud_host.getActUrl(opts.act);
var params = opts.req || {};
params = fhparams.addFHParams(params);
var headers = fhparams.getFHHeaders();
if (opts.headers) {
headers = _.extend(headers, opts.headers);
Expand Down Expand Up @@ -51,4 +50,4 @@ module.exports = function(opts, success, fail){
doActCall(opts, success, fail);
}
});
};
};
3 changes: 1 addition & 2 deletions src/modules/api_cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ function doCloudCall(opts, success, fail){
var cloud_host = cloud.getCloudHost();
var url = cloud_host.getCloudUrl(opts.path);
var params = opts.data || {};
params = fhparams.addFHParams(params);
var type = opts.method || "POST";
var data;
if (["POST", "PUT", "PATCH", "DELETE"].indexOf(type.toUpperCase()) !== -1) {
Expand Down Expand Up @@ -55,4 +54,4 @@ module.exports = function(opts, success, fail){
doCloudCall(opts, success, fail);
}
});
};
};

0 comments on commit 6827e03

Please sign in to comment.