camelize-http

camelize-http

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

GET

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 });

POST

var data = { camelizedKey: 42 };

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

Contribute / Roadmap

Implement remaining shortcut methods

  • HEAD
  • PUT
  • DELETE
  • JSONP

Support all arguments in success/error promises

License

MIT

comments powered by Disqus
This page was last updated about 3 years ago.