request-json is a Node.js HTTP client specifically designed to streamline interactions with JSON APIs. It acts as a wrapper around the now-deprecated `request` library, simplifying common tasks like sending and receiving JSON payloads, handling basic authentication, and uploading/downloading files. Currently at version 0.6.5, the package has seen no updates for several years, effectively rendering it unmaintained. Its core differentiator was abstracting away some complexities of the underlying `request` library, offering a more fluent API for JSON-centric operations and basic promise support via `.then()`. Due to its fundamental dependency on the unmaintained `request` package, `request-json` should be considered unstable and potentially insecure for new projects, with no ongoing release cadence.
npm install request-jsonVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the request-json client and perform various HTTP methods (POST, GET, PUT, DELETE, PATCH) to a mock API endpoint, including basic authentication and custom headers. It showcases both callback-based and promise-based approaches.
Migrate to a modern, actively maintained HTTP client like `axios`, `node-fetch`, or `undici`. If migrating from `request`, consider `got` as a direct successor.
Always use `request.createClient()` instead of `new request.newClient()`.
Ensure both `err` argument in callbacks and `.catch()` blocks for promises are implemented to handle network or API errors gracefully.
Continue using `require('request-json')` in CommonJS environments. For ES module environments, a wrapper or re-bundling might be necessary, or ideally, migrate to a native ESM-compatible HTTP client.Verify the expected key names for file uploads on your target API and adapt the `request-json` usage or implement custom file handling if necessary.
While this specific warning cannot be 'fixed' within `request-json` without updating its core dependency, it signals an urgent need to migrate away from `request-json` to a modern HTTP client library for security and stability reasons.
Ensure `const request = require('request-json');` is correctly placed and `createClient()` is called directly on the imported `request` object: `const client = request.createClient('http://localhost:8888/');`.Always chain a `.catch(err => { console.error(err); })` to any promise-returning `request-json` method to handle potential errors.