Registry / http-networking / angularjs-http-batcher

angularjs-http-batcher

JSON →
library1.13.0jsnpmunverified

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-batcher
INSTALL
IMPORT
SIG · ANGULARJS-HTTP-BAT
A
angularjs-http-batcher
http-networkingjavascriptv1.13.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jcs.angular-http-batch
angular.module('myApp', ['jcs.angular-http-batch']);
import { httpBatch } from 'angularjs-http-batcher';
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`.
httpBatchConfigProvider
app.config(['httpBatchConfigProvider', function(httpBatchConfigProvider) { ... }]);
app.config(['HttpBatchConfigProvider', function(HttpBatchConfigProvider) { ... }]);
The provider name follows Angular's camelCase convention for injection; ensure correct casing and suffix 'Provider' when injecting into a config block.
httpBatchAdapter
{ adapter: 'httpBatchAdapter' }
{ adapter: HttpBatchAdapter }
Adapter names are string literals specified in the configuration options, not direct object references.

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.

<!-- Include the AngularJS library first --> <script src="node_modules/angular/angular.min.js"></script> <!-- Then include the http-batcher library --> <script src="node_modules/angularjs-http-batcher/dist/angular-http-batch.min.js"></script> <script> angular.module('myApp', ['jcs.angular-http-batch']) .config([ 'httpBatchConfigProvider', function (httpBatchConfigProvider) { httpBatchConfigProvider.setAllowedBatchEndpoint( // Root endpoint URL of your API 'http://api.myapp.com', // The specific endpoint that accepts batch requests 'http://api.myapp.com/batch', // Optional configuration parameters { maxBatchedRequestPerCall: 20, minimumBatchSize: 2, batchRequestCollectionDelay: 100, ignoredVerbs: ['HEAD', 'OPTIONS'], // Do not batch these verbs sendCookies: true, enabled: true, adapter: 'httpBatchAdapter' // Defaults to HTTP 1.1 adapter } ); } ]); angular.module('myApp') .controller('MyController', ['$http', function($http) { console.log('Fetching user data...'); $http.get('http://api.myapp.com/users/1').then(res => console.log('User 1:', res.data)); $http.get('http://api.myapp.com/users/2').then(res => console.log('User 2:', res.data)); $http.get('http://api.myapp.com/products/10').then(res => console.log('Product 10:', res.data)); // These three GET requests to 'http://api.myapp.com' will be batched if within the delay window }]); // Manually bootstrap the Angular app angular.element(document).ready(function() { angular.bootstrap(document, ['myApp']); }); </script> <div ng-app="myApp" ng-controller="MyController"> <h1>HTTP Batching Demo</h1> <p>Check your browser's network tab for batched HTTP requests.</p> </div>
Debug
Known issues
breakingThis 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.
fix
For Angular 2+ projects, install and configure `ngx-http-batcher`. Do not attempt to use `angularjs-http-batcher` in modern Angular applications.
affects: All versions
gotchaThe library will only batch requests if they are directed at an endpoint whose root URL has been explicitly registered with `httpBatchConfigProvider.setAllowedBatchEndpoint`.
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.
affects: >=1.0.0
gotchaBatching 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.
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.
affects: >=1.0.0
gotchaCertain 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.
fix
In the `setAllowedBatchEndpoint` options, explicitly set `ignoredVerbs: []` or specify an array of verbs you still wish to ignore. For example: `ignoredVerbs: ['OPTIONS']`.
affects: >=1.0.0
Errors
Common errors & fixes
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.
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.
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.
Unknown provider: httpBatchConfigProviderProvider
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.
fix
Verify that `angular.module('myApp', ['jcs.angular-http-batch'])` correctly lists the batcher module and that its JavaScript file is loaded.
Cannot read property 'setAllowedBatchEndpoint' of undefined
The `httpBatchConfigProvider` was not successfully injected into the config block, likely due to a misspelling or the module not being loaded.
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.
Upgrade
Version history
1.13.0latest on npm
Audit
Dependencies
angularrequiredRuntime peer dependency for AngularJS applications.
Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
1
Resources
angularjs-http-batcher — npm install angularjs-http-batcher · libregistry