{"id":17158,"library":"angularjs-http-batcher","title":"AngularJS HTTP Batcher","description":"The angularjs-http-batcher library provides a transparent mechanism to batch multiple outgoing HTTP requests into a single network call within AngularJS (Angular 1.x) applications. This significantly improves application performance by reducing the number of round trips to the server. The library intercepts standard `$http` requests and, if destined for a configured batch endpoint, combines them according to the HTTP 1.1 batch specification, which is commonly used by .NET Web API and Java servers. It also includes an adapter for Node.js multifetch and aims to support Facebook's batching protocol. Version 1.13.0 is the current stable release. Its key differentiator is the 'transparent' nature of batching, requiring minimal configuration and no specific batching calls from the developer, making it simple to integrate into existing AngularJS applications. This package is specifically for AngularJS and is not compatible with Angular 2+.","status":"maintenance","version":"1.13.0","language":"javascript","source_language":"en","source_url":"https://github.com/Omninox/angular-http-batcher","tags":["javascript","angularjs","performance","http","http batch","angular 1","batch request"],"install":[{"cmd":"npm install angularjs-http-batcher","lang":"bash","label":"npm"},{"cmd":"yarn add angularjs-http-batcher","lang":"bash","label":"yarn"},{"cmd":"pnpm add angularjs-http-batcher","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Runtime peer dependency for AngularJS applications.","package":"angular","optional":false}],"imports":[{"note":"This is an AngularJS module. Its functionality is exposed by adding it as a dependency to your main Angular app module, not via ES module imports or CommonJS `require`.","wrong":"import { httpBatch } from 'angularjs-http-batcher';","symbol":"jcs.angular-http-batch","correct":"angular.module('myApp', ['jcs.angular-http-batch']);"},{"note":"The provider name follows Angular's camelCase convention for injection; ensure correct casing and suffix 'Provider' when injecting into a config block.","wrong":"app.config(['HttpBatchConfigProvider', function(HttpBatchConfigProvider) { ... }]);","symbol":"httpBatchConfigProvider","correct":"app.config(['httpBatchConfigProvider', function(httpBatchConfigProvider) { ... }]);"},{"note":"Adapter names are string literals specified in the configuration options, not direct object references.","wrong":"{ adapter: HttpBatchAdapter }","symbol":"httpBatchAdapter","correct":"{ adapter: 'httpBatchAdapter' }"}],"quickstart":{"code":"<!-- Include the AngularJS library first -->\n<script src=\"node_modules/angular/angular.min.js\"></script>\n<!-- Then include the http-batcher library -->\n<script src=\"node_modules/angularjs-http-batcher/dist/angular-http-batch.min.js\"></script>\n\n<script>\n  angular.module('myApp', ['jcs.angular-http-batch'])\n    .config([\n      'httpBatchConfigProvider',\n      function (httpBatchConfigProvider) {\n        httpBatchConfigProvider.setAllowedBatchEndpoint(\n          // Root endpoint URL of your API\n          'http://api.myapp.com',\n          // The specific endpoint that accepts batch requests\n          'http://api.myapp.com/batch',\n          // Optional configuration parameters\n          {\n            maxBatchedRequestPerCall: 20,\n            minimumBatchSize: 2,\n            batchRequestCollectionDelay: 100,\n            ignoredVerbs: ['HEAD', 'OPTIONS'], // Do not batch these verbs\n            sendCookies: true,\n            enabled: true,\n            adapter: 'httpBatchAdapter' // Defaults to HTTP 1.1 adapter\n          }\n        );\n      }\n    ]);\n\n  angular.module('myApp')\n    .controller('MyController', ['$http', function($http) {\n      console.log('Fetching user data...');\n      $http.get('http://api.myapp.com/users/1').then(res => console.log('User 1:', res.data));\n      $http.get('http://api.myapp.com/users/2').then(res => console.log('User 2:', res.data));\n      $http.get('http://api.myapp.com/products/10').then(res => console.log('Product 10:', res.data));\n      // These three GET requests to 'http://api.myapp.com' will be batched if within the delay window\n    }]);\n\n  // Manually bootstrap the Angular app\n  angular.element(document).ready(function() {\n    angular.bootstrap(document, ['myApp']);\n  });\n</script>\n<div ng-app=\"myApp\" ng-controller=\"MyController\">\n  <h1>HTTP Batching Demo</h1>\n  <p>Check your browser's network tab for batched HTTP requests.</p>\n</div>","lang":"javascript","description":"This quickstart demonstrates how to include the `angularjs-http-batcher` library, configure a batch endpoint, and show how typical `$http` GET requests are transparently batched."},"warnings":[{"fix":"For Angular 2+ projects, install and configure `ngx-http-batcher`. Do not attempt to use `angularjs-http-batcher` in modern Angular applications.","message":"This library is specifically designed for AngularJS (Angular 1.x). It is not compatible with Angular 2+ applications. For Angular 2 and later, use `ngx-http-batcher` instead.","severity":"breaking","affected_versions":"All versions"},{"fix":"Ensure `httpBatchConfigProvider.setAllowedBatchEndpoint(rootUrl, batchEndpointUrl, options)` is correctly configured in your application's `.config()` block, specifying the base URL of your API and the dedicated batch endpoint.","message":"The library will only batch requests if they are directed at an endpoint whose root URL has been explicitly registered with `httpBatchConfigProvider.setAllowedBatchEndpoint`.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Adjust `batchRequestCollectionDelay` and `maxBatchedRequestPerCall` in `setAllowedBatchEndpoint` options to match your application's typical request patterns and server capabilities. Be mindful that very short delays might not capture enough requests, while very long ones could introduce perceived latency.","message":"Batching is asynchronous and occurs after a short `batchRequestCollectionDelay`. Requests made within this delay window will be grouped. Requests outside this window or that exceed `maxBatchedRequestPerCall` will be sent individually or in new batches.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"In the `setAllowedBatchEndpoint` options, explicitly set `ignoredVerbs: []` or specify an array of verbs you still wish to ignore. For example: `ignoredVerbs: ['OPTIONS']`.","message":"Certain HTTP verbs are ignored by default (e.g., 'HEAD'). If you need to batch these or other specific verbs, you must override the `ignoredVerbs` option.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Ensure `<script src=\"path/to/angular-http-batch.min.js\"></script>` is present in your HTML *after* AngularJS itself, and verify `angular.module('myApp', ['jcs.angular-http-batch'])` has the correct module name.","cause":"The `angular-http-batch.min.js` script file was not included in the HTML, or the module name `'jcs.angular-http-batch'` was misspelled when declaring application dependencies.","error":"Module 'jcs.angular-http-batch' is not available! You either misspelled the module name or forgot to load it. If error is for a module this means the module itself is not loaded."},{"fix":"Verify that `angular.module('myApp', ['jcs.angular-http-batch'])` correctly lists the batcher module and that its JavaScript file is loaded.","cause":"The `httpBatchConfigProvider` was requested in an Angular configuration block, but the `jcs.angular-http-batch` module has not been loaded or correctly declared as a dependency of the main application module.","error":"Unknown provider: httpBatchConfigProviderProvider"},{"fix":"Check the spelling of `httpBatchConfigProvider` in your config function's argument list and array declaration. Also, ensure the main Angular module correctly lists `'jcs.angular-http-batch'` as a dependency.","cause":"The `httpBatchConfigProvider` was not successfully injected into the config block, likely due to a misspelling or the module not being loaded.","error":"Cannot read property 'setAllowedBatchEndpoint' of undefined"}],"ecosystem":"npm","meta_description":null}