{"library":"scoped-http-client","title":"Scoped HTTP Client for Node.js","description":"Scoped HTTP Client provides a fluent, chainable API wrapper around Node.js's native `http` client, simplifying common HTTP request patterns. Instead of handling numerous optional arguments directly on `http.request`, it allows developers to build requests by chaining methods like `.header()`, `.path()`, `.query()`, and `.get()`/`.post()`. A key feature is its 'scoping' mechanism, enabling temporary modifications to client parameters for specific requests without altering the base client instance. The package's current stable version is 0.11.0, last published in 2015. Given its age and an `engines` declaration targeting `node >= 0.8.0`, it is no longer actively maintained and is likely incompatible with modern Node.js environments. Its approach to request building has largely been superseded by contemporary HTTP clients like Axios, Got, or the native Fetch API, which offer more robust features, Promises/async-await support, and active maintenance.","language":"javascript","status":"abandoned","last_verified":"Tue Apr 21","install":{"commands":["npm install scoped-http-client"],"cli":null},"imports":["const scopedClient = require('scoped-http-client');","const client = scopedClient.create('https://api.example.com');","client.header('Accept', 'application/json').get()(callback);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const scopedClient = require('scoped-http-client');\nconst util = require('util'); // Node.js built-in module\n\n// Example 1: Basic GET request\nconst githubClient = scopedClient.create('https://api.github.com')\n  .header('accept', 'application/json')\n  .path('users/technoweenie')\n  .get()(function(err, resp, body) {\n    if (err) {\n      console.error('Error fetching user:', err);\n      return;\n    }\n    console.log('GET Response Status:', resp.statusCode);\n    util.puts('User Info: ' + body);\n  });\n\n// Example 2: POST request within a scope\nconst token = process.env.GITHUB_TOKEN ?? 'YOUR_DUMMY_GITHUB_TOKEN'; // Replace with a real token or handle auth\nconst scopedBaseClient = scopedClient.create('https://api.github.com')\n  .query({ token: token });\n\nscopedBaseClient.scope('user/repos', function(cli) {\n  const data = JSON.stringify({ name: 'my-new-repo', description: 'A test repository' });\n  cli.post(data)(function(err, resp, body) {\n    if (err) {\n      console.error('Error creating repo:', err);\n      return;\n    }\n    console.log('POST Response Status:', resp.statusCode);\n    util.puts('Repo creation response: ' + body);\n  });\n});","lang":"javascript","description":"Demonstrates creating a client, chaining methods for headers and paths, executing a GET request, and making a POST request within a scoped context, including basic error handling.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}