{"id":17352,"library":"requisition","title":"Requisition HTTP Client","description":"Requisition is a lightweight, fluent HTTP client designed specifically for Node.js, with a strong emphasis on ES6/ES7 `async/await` patterns. It provides a minimal API for making HTTP requests (GET, POST, etc.) and offers utilities for handling responses, such as parsing JSON, reading as text or buffer, and saving to a file. Unlike browser-compatible alternatives like Axios, Requisition focuses solely on the Node.js environment, foregoing large options objects in favor of a chainable, method-based interface. The package is currently at version 1.7.0, with its last update nearly seven years ago (June 2017), indicating it is no longer actively maintained and should be considered abandoned. Due to its age, it targets older Node.js versions and exclusively uses CommonJS modules.","status":"abandoned","version":"1.7.0","language":"javascript","source_language":"en","source_url":"https://github.com/thenables/requisition","tags":["javascript","request","promise","http","https","client"],"install":[{"cmd":"npm install requisition","lang":"bash","label":"npm"},{"cmd":"yarn add requisition","lang":"bash","label":"yarn"},{"cmd":"pnpm add requisition","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Requisition is a CommonJS-only package. Attempting to use `import` syntax will result in an `ERR_REQUIRE_ESM` error in modern Node.js environments.","wrong":"import req from 'requisition';","symbol":"req","correct":"const req = require('requisition');"},{"note":"The primary export is a function, often aliased as `request` or `req`, which initiates an HTTP request chain. Named imports are not supported.","wrong":"import { request } from 'requisition';","symbol":"request","correct":"const request = require('requisition');"},{"note":"There is no `Request` class or named export. The README sometimes refers to the `request` function as 'Request' in its API documentation, which can be confusing. The default export is a function to create a new request.","wrong":"import { Request } from 'requisition';","symbol":"Request","correct":"const Request = require('requisition');\n// Request is the function itself, not a class or named export"}],"quickstart":{"code":"const req = require('requisition');\n\nasync function fetchAndSaveUser(userId) {\n  try {\n    console.log(`Fetching user ${userId}...`);\n    const userResponse = await req(`/users/${userId}.json`);\n\n    if (userResponse.status !== 200) {\n      console.error(`Error fetching user ${userId}: Status ${userResponse.status}`);\n      await userResponse.dump(); // Consume unhandled body to prevent memory leaks\n      return;\n    }\n\n    const userData = await userResponse.json();\n    console.log(`User ${userId} data:`, userData);\n\n    // Example: Save an image if the user had one (hypothetical)\n    if (userData.profileImage) {\n      console.log(`Fetching profile image for user ${userId}...`);\n      const imageResponse = await req(userData.profileImage);\n      if (imageResponse.status === 200) {\n        const savedPath = await imageResponse.saveTo(`/tmp/user_${userId}_profile.png`);\n        console.log(`Profile image saved to: ${savedPath}`);\n      } else {\n        console.warn(`Could not fetch profile image for user ${userId}: Status ${imageResponse.status}`);\n        await imageResponse.dump();\n      }\n    }\n\n  } catch (error) {\n    console.error('An error occurred during the request:', error.message);\n  }\n}\n\n// To run this example, you'd need a simple local server\n// For demonstration purposes, assume '/users/123.json' and '/users/123/image.png' exist\n\n// Example usage (in an async IIFE or main function):\n(async () => {\n  await fetchAndSaveUser(123);\n  await fetchAndSaveUser(456);\n})();","lang":"javascript","description":"This quickstart demonstrates how to make a GET request to fetch user data, parse a JSON response, handle different HTTP statuses, and conditionally save a related file to disk, all using `async/await` with `requisition`."},"warnings":[{"fix":"Use CommonJS `const req = require('requisition');` or consider migrating to a modern HTTP client that supports ESM like `node-fetch` or `axios`.","message":"The package is explicitly CommonJS (CJS) only, with its last update in June 2017. It does not support ES modules (ESM) natively, and attempting `import requisition` will result in `ERR_REQUIRE_ESM` errors in modern Node.js projects configured for ESM.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Avoid using in new projects. For existing projects, consider a migration plan to a actively maintained HTTP client to ensure security, performance, and compatibility with current Node.js ecosystems.","message":"Requisition is an abandoned package, last updated almost seven years ago. This means it lacks support for modern Node.js features, HTTP/2 or HTTP/3, and may contain unpatched security vulnerabilities or rely on outdated internal dependencies.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Explicitly use `try...catch` for all `await` expressions to gracefully handle network errors, timeouts, and HTTP response errors. Ensure you consume response bodies (e.g., `await res.json()`, `res.dump()`) even on error to prevent resource leaks.","message":"Error handling with `async/await` in older Node.js versions (which this package targets) might be less robust for unhandled promise rejections compared to modern environments. Always wrap `await` calls in `try...catch` blocks.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Thoroughly test cookie handling to ensure compatibility with your target server. For more advanced cookie management, consider external libraries or manual header manipulation if `.cookie()` doesn't meet needs.","message":"The `.cookie()` method for setting cookies uses `cookie.serialize()`, but the response's `.cookies` property provides parsed cookies. Manual handling of cookie string parsing/serializing might be needed for complex scenarios or specific server requirements.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Change `import req from 'requisition';` to `const req = require('requisition');`.","cause":"Attempting to `import requisition` in an ES module context.","error":"ERR_REQUIRE_ESM"},{"fix":"Ensure your bundler is configured to correctly handle CommonJS modules, or preferably, use `require('requisition')` if possible. Best to migrate to a modern, ESM-compatible HTTP client.","cause":"This error occurs in a bundler environment (like Webpack) when `requisition` (a CJS module) is imported as a default ESM import, and the bundler tries to resolve a non-existent default export.","error":"TypeError: (0 , requisition__WEBPACK_IMPORTED_MODULE_0__.default) is not a function"},{"fix":"Increase the request timeout using `.timeout(ms)` or investigate server-side logs for the remote service. Check for network connectivity or proxy configuration issues. Ensure the server is not closing the connection due to malformed requests.","cause":"The remote server closed the connection prematurely, often due to a server-side error, proxy issues, or the request taking too long without proper timeout handling.","error":"Error: socket hang up"},{"fix":"Verify that the target server is running and accessible at the specified URL and port. Check firewall settings on both client and server machines.","cause":"The client could not establish a connection to the server, typically because the server is not running, is on a different port, or a firewall is blocking the connection.","error":"Error: connect ECONNREFUSED"}],"ecosystem":"npm","meta_description":null}