Registry / http-networking / ajax-request

ajax-request

JSON →
library1.2.3jsnpmunverified

ajax-request is a basic, callback-based HTTP client library designed for Node.js, offering functionalities for sending GET and POST requests, as well as direct file downloads. Currently at version 1.2.3, this package appears to have an inactive or ceased release cadence, with its last update occurring approximately 8 years ago. Key differentiators include its straightforward API for common HTTP operations and built-in file downloading, which was more unique at the time of its active development. However, it significantly lags behind modern HTTP clients, lacking support for Promises/async-await and ES Modules, and does not ship with TypeScript definitions. The `base64` utility method has been deprecated and migrated to a separate package, signaling a lack of ongoing maintenance for this core library.

npm install ajax-request
INSTALL
IMPORT
SIG · AJAX-REQUEST
A
ajax-request
http-networkingjavascriptv1.2.3
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.

request
const request = require('ajax-request');
import request from 'ajax-request';
This package is CommonJS-only and does not support ES module `import` syntax. Attempting to use `import` will result in a runtime error.
request.post
const request = require('ajax-request'); request.post(options, callback);
import { post } from 'ajax-request';
The `post` method is available as a property of the default `request` export in CommonJS. It is not a named export for ES Modules.
request.download
const request = require('ajax-request'); request.download(options, callback);
import { download } from 'ajax-request';
The `download` method is available as a property of the default `request` export in CommonJS. It is not a named export for ES Modules.

This quickstart demonstrates how to perform a simple GET request, a POST request with JSON data, and download a file using the callback-based API of `ajax-request`.

const request = require('ajax-request'); // Example 1: Basic GET request request('https://jsonplaceholder.typicode.com/posts/1', function(err, res, body) { if (err) { console.error('GET Error:', err); return; } console.log('GET Response (Status Code):', res.statusCode); console.log('GET Response (Body):', JSON.parse(body)); }); // Example 2: POST request with data request({ url: 'https://jsonplaceholder.typicode.com/posts', method: 'POST', data: { title: 'foo', body: 'bar', userId: 1 }, json: true // Automatically parse response body as JSON }, function(err, res, body) { if (err) { console.error('POST Error:', err); return; } console.log('POST Response (Status Code):', res.statusCode); console.log('POST Response (Body):', body); }); // Example 3: Download a file (replace with a real, small file URL for testing) // NOTE: This will attempt to save a file to the current working directory. const fs = require('fs'); const tempFilePath = './downloaded-image.png'; request.download({ url: 'https://via.placeholder.com/150/FF0000/FFFFFF?text=Test', destPath: tempFilePath }, function(err, res, body, destpath) { if (err) { console.error('Download Error:', err); return; } console.log(`File downloaded to: ${destpath}`); // Verify file existence (optional) if (fs.existsSync(tempFilePath)) { console.log('Downloaded file exists!'); fs.unlinkSync(tempFilePath); // Clean up } });
Debug
Known issues
gotchaThe `ajax-request` package is significantly outdated (v1.2.3, last published ~8 years ago) and appears to be unmaintained. It lacks modern features like Promise-based APIs or `async/await` support, relying solely on callbacks.
fix
Consider migrating to a modern HTTP client library for Node.js such as `axios`, `node-fetch`, or the built-in `fetch` API (available in Node.js >= 18) for better security, features, and maintainability.
affects: <=1.2.3
breakingThe package is CommonJS-only and does not support ES Modules. Attempting to use `import` syntax will result in a runtime `ERR_REQUIRE_ESM` error.
fix
Ensure your project uses `require()` for importing `ajax-request`. For new projects, consider using a modern library that supports ES Modules or the native Node.js `fetch` API.
affects: >=1.0.0
deprecatedThe `request.base64` method has been explicitly deprecated and moved to a separate package. Its functionality is no longer part of `ajax-request`.
fix
For base64 image functionality, refer to the `base64-img` package or implement the conversion manually using Node.js's built-in `Buffer` and file system modules.
affects: >=1.2.0
gotchaDue to its age, `ajax-request` might not correctly handle modern TLS/SSL certificates, leading to `UNABLE_TO_VERIFY_LEAF_SIGNATURE` or similar errors when connecting to contemporary HTTPS endpoints. It also lacks explicit security updates for potential vulnerabilities.
fix
Migrate to a actively maintained HTTP client. If immediate migration is not possible, for testing or specific controlled environments, Node.js can be run with `NODE_TLS_REJECT_UNAUTHORIZED='0'` (NOT recommended for production) or a custom agent with `rejectUnauthorized: false` for `http.request` based calls, but this is a significant security risk.
affects: <=1.2.3
gotchaThe package does not ship with TypeScript type definitions, leading to poor developer experience and lack of type safety in TypeScript projects.
fix
Manually create declaration files (e.g., `ajax-request.d.ts`) or use a modern HTTP client that provides official TypeScript support.
affects: >=1.0.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module [path] not supported
Attempting to `import` the `ajax-request` package in an ES Module context.
fix
Change `import request from 'ajax-request';` to `const request = require('ajax-request');` and ensure your project is configured for CommonJS or uses dynamic `import()` if mixed modules are necessary.
TypeError: callback is not a function
The request method (or its variants) was called without providing a callback function as the last argument.
fix
Ensure that a function is passed as the `callback` argument to `request()`, `request.post()`, or `request.download()` methods.
Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE
The Node.js environment failed to verify the SSL certificate of the target server, often due to an outdated root certificate store or a self-signed certificate.
fix
Update Node.js to a recent version. If the server uses a self-signed certificate in a controlled environment, you might temporarily set `NODE_TLS_REJECT_UNAUTHORIZED='0'` (NOT for production) or add the certificate to your trusted store. The best fix is to migrate to a modern, maintained HTTP client library.
Upgrade
Version history
1.2.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
22
OpenAI (training)
1
Resources