{"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.","language":"javascript","status":"abandoned","last_verified":"Wed Apr 22","install":{"commands":["npm install requisition"],"cli":null},"imports":["const req = require('requisition');","const request = require('requisition');","const Request = require('requisition');\n// Request is the function itself, not a class or named export"],"auth":{"required":false,"env_vars":[]},"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`.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}