Skip to content

Instantly share code, notes, and snippets.

@lucasbento
Last active March 17, 2016 10:49
Show Gist options
  • Save lucasbento/3c9be78d775e8a698f8e to your computer and use it in GitHub Desktop.
Save lucasbento/3c9be78d775e8a698f8e to your computer and use it in GitHub Desktop.
AngularJS 1.4.x workaround to work with CakePHP 2.x REST API.
(function() {
'use strict';
angular
.module('app')
.config(config);
config.$inject = ['$httpProvider'];
/** @ngInject */
function config($httpProvider) {
$httpProvider.defaults.transformRequest = function(data){
if (data === undefined)
return data;
return $.param(data);
};
$httpProvider.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded; charset=UTF-8;";
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment