{"id":17348,"library":"request-json","title":"Simplified JSON HTTP Client","description":"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.","status":"abandoned","version":"0.6.5","language":"javascript","source_language":"en","source_url":"git://github.com/hackervents/request-json","tags":["javascript","requests","request","api","http","json","client","simple","utility"],"install":[{"cmd":"npm install request-json","lang":"bash","label":"npm"},{"cmd":"yarn add request-json","lang":"bash","label":"yarn"},{"cmd":"pnpm add request-json","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core HTTP client library; deprecated on February 11, 2020, and no longer maintained. This critically impacts request-json's viability and security.","package":"request"}],"imports":[{"note":"This package is CommonJS-only and does not provide ES module exports. Direct import of the module is usually followed by calling `createClient()`.","wrong":"import request from 'request-json'","symbol":"request","correct":"const request = require('request-json');"},{"note":"The `newClient()` method is deprecated in favor of `createClient()` and will emit a warning, although it remains functional.","wrong":"const client = new request.newClient('http://localhost:8888/');","symbol":"createClient","correct":"const client = request.createClient('http://localhost:8888/');"},{"note":"Most client methods (`get`, `post`, `put`, `del`, `patch`, `sendFile`, `saveFile`) primarily accept a callback, but also return a Promise for `.then().catch()` usage.","symbol":"post","correct":"client.post('posts/', data, (err, res, body) => { /* ... */ });"}],"quickstart":{"code":"const request = require('request-json');\nconst client = request.createClient('http://localhost:8888/');\n\nconsole.log('--- Simulating API calls to http://localhost:8888/ ---');\n\n// POST request\nconst postData = {\n  title: 'my title',\n  content: 'my content'\n};\nclient.post('posts/', postData, function(err, res, body) {\n  if (err) return console.error('POST Error:', err);\n  console.log(`POST /posts/ Status: ${res.statusCode}`);\n  // console.log('POST Body:', body); // In a real scenario, body would contain the API's response\n});\n\n// GET request\nclient.get('posts/', function(err, res, body) {\n  if (err) return console.error('GET Error:', err);\n  console.log(`GET /posts/ Status: ${res.statusCode}`);\n  // console.log('GET Body (first title):', body?.rows?.[0]?.title); // Assuming a structure, this would be undefined without a real server\n});\n\n// PUT request\nconst putData = {\n  title: 'my new title'\n};\nclient.put('posts/123/', putData, function(err, res, body) {\n  if (err) return console.error('PUT Error:', err);\n  console.log(`PUT /posts/123/ Status: ${res.statusCode}`);\n});\n\n// DELETE request\nclient.del('posts/123/', function(err, res, body) {\n  if (err) return console.error('DEL Error:', err);\n  console.log(`DEL /posts/123/ Status: ${res.statusCode}`);\n});\n\n// PATCH request with Promises\nconst patchData = {\n  title: 'my patched title'\n};\nclient.patch('posts/123/', patchData)\n  .then(function(result) {\n    console.log(`PATCH /posts/123/ Status: ${result.res.statusCode}`);\n    // console.log('PATCH Body:', result.body);\n  })\n  .catch(err => {\n    console.error('PATCH Error:', err);\n  });\n\n// Basic Authentication example\nclient.setBasicAuth('john', 'secret');\nclient.get('private/posts/', function(err, res, body) {\n  if (err) return console.error('Auth GET Error:', err);\n  console.log(`Authenticated GET /private/posts/ Status: ${res.statusCode}`);\n});\n\n// Headers manipulation\nclient.headers['X-Custom-Header'] = 'MyValue';\nconsole.log('Client configured with X-Custom-Header.');\n","lang":"javascript","description":"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."},"warnings":[{"fix":"Migrate to a modern, actively maintained HTTP client like `axios`, `node-fetch`, or `undici`. If migrating from `request`, consider `got` as a direct successor.","message":"The underlying `request` library, which `request-json` relies on, was fully deprecated on February 11, 2020. This means `request-json` is built on an unmaintained and potentially insecure foundation, lacking future updates, bug fixes, or security patches.","severity":"breaking","affected_versions":">=0.0.1"},{"fix":"Always use `request.createClient()` instead of `new request.newClient()`.","message":"The `newClient()` method is deprecated. While still functional, it will emit a deprecation warning.","severity":"deprecated","affected_versions":"<=0.6.5"},{"fix":"Ensure both `err` argument in callbacks and `.catch()` blocks for promises are implemented to handle network or API errors gracefully.","message":"Error handling typically relies on Node.js-style callbacks (`(err, res, body) => {}`) where the first argument is an error. For promise-based calls, `.catch()` should be used.","severity":"gotcha","affected_versions":"<=0.6.5"},{"fix":"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.","message":"The package uses CommonJS `require()` syntax exclusively. It does not provide native ES module exports, which is the standard for modern JavaScript projects.","severity":"gotcha","affected_versions":"<=0.6.5"},{"fix":"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.","message":"File upload methods (`sendFile`) have specific key naming conventions (`'file'` for single files, `'file0', 'file1', ...` for arrays) which might not align with all API expectations, requiring server-side adaptation or careful client-side data preparation.","severity":"gotcha","affected_versions":"<=0.6.5"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"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.","cause":"This warning appears because `request-json` depends on the `request` package, which is no longer maintained.","error":"npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142"},{"fix":"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/');`.","cause":"Attempting to use `new` keyword with `createClient()` or calling `createClient` before requiring `request-json`.","error":"TypeError: request.createClient is not a function"},{"fix":"Always chain a `.catch(err => { console.error(err); })` to any promise-returning `request-json` method to handle potential errors.","cause":"A promise-returning method (e.g., `client.get().then(...)`) encountered an error, but no `.catch()` handler was provided.","error":"UnhandledPromiseRejectionWarning: Unhandled promise rejection."}],"ecosystem":"npm","meta_description":null}