{"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.","language":"javascript","status":"abandoned","last_verified":"Wed Apr 22","install":{"commands":["npm install request-json"],"cli":null},"imports":["const request = require('request-json');","const client = request.createClient('http://localhost:8888/');","client.post('posts/', data, (err, res, body) => { /* ... */ });"],"auth":{"required":false,"env_vars":[]},"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.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}