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+.
npm install angularjs-http-batcherVerified import paths — ran on the pinned version, not inferred.
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.
For Angular 2+ projects, install and configure `ngx-http-batcher`. Do not attempt to use `angularjs-http-batcher` in modern Angular applications.
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.
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.
In the `setAllowedBatchEndpoint` options, explicitly set `ignoredVerbs: []` or specify an array of verbs you still wish to ignore. For example: `ignoredVerbs: ['OPTIONS']`.
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.Verify that `angular.module('myApp', ['jcs.angular-http-batch'])` correctly lists the batcher module and that its JavaScript file is loaded.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.