Skip to content

Instantly share code, notes, and snippets.

@meetwudi
Created March 26, 2014 10:29
Show Gist options
  • Save meetwudi/9780455 to your computer and use it in GitHub Desktop.
Save meetwudi/9780455 to your computer and use it in GitHub Desktop.
angular.module('App').config(function (RestangularProvider) {
// convert json request to x-www-form-urlencoded request
RestangularProvider.setFullRequestInterceptor(function (el, op, what, url) {
if (op === "put" || op === "post") {
var res = "";
_.forOwn(el, function (v, k) {
if (!_.isFunction(v)) {
res += k + "=" + encodeURIComponent(v) + "&";
}
});
return {
headers : { "Content-Type": "application/x-www-form-urlencoded" },
element : res.substr(0, res.length - 1),
params : {}
}
}
return {
headers : {},
element : el,
params : {}
};
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment