This tiny AngularJS module wraps around the core $http service, with the single responsibility of eliminating discrepancies between underscored_keys from/to backends (e.g. Python, Ruby) and camelizedKeys in the front-end.

Installation using Bower

Quick Start

Step 1

Include the module (after angular.js)

Step 2

Tell your angular app that it depends on the module

angular.module('YourApp', ['camelizeHttp']);

Step 3

Inject cHttp wrapper into an angular component

angular.module('YourApp').service('SomeComponent', function(cHttp) { // ... });

Usage Examples

Once you have the wrapper, use it as you would use the core $http service


cHttp.get('/some-endpoint').success(function(response) { // The original response from the server contains underscored_keys, // but the response received here has been converted to camelizedKeys });


var data = { camelizedKey: 42 };

// Although the post params are camel case, // the server will receive data with underscore keys: { camelized_key: 42 };'/some-endpoint', data).success(function(response) { // And the response is still converted to camel case });

Contribute / Roadmap

Implement remaining shortcut methods

  • HEAD
  • PUT

Support all arguments in success/error promises



comments powered by Disqus
This page was last updated over 2 years ago.