{"id":16565,"library":"unirest","title":"Unirest HTTP Client for Node.js","description":"Unirest for Node.js is a lightweight HTTP client library designed to simplify common HTTP request patterns, including GET, POST, PUT, and file uploads. It offers features like automatic gzip decompression and response parsing, aiming to provide a concise, fluent API. The library's development has been dormant for approximately seven years, with its last stable version (0.11.0) published in 2017. Consequently, it lacks ongoing maintenance and a current release cadence. While it was once part of a multi-language HTTP library suite and associated with Kong, it is now largely superseded by more modern and actively maintained alternatives in the Node.js ecosystem, such as `axios` or `node-fetch`. Developers should be aware of its unmaintained status and potential compatibility issues with newer Node.js versions.","status":"abandoned","version":"0.6.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/Mashape/unirest-nodejs","tags":["javascript","request","http","library","superagent","simple","util","utility","method"],"install":[{"cmd":"npm install unirest","lang":"bash","label":"npm"},{"cmd":"yarn add unirest","lang":"bash","label":"yarn"},{"cmd":"pnpm add unirest","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Unirest for Node.js is an older, CommonJS-only library. Attempting to use ES module `import` syntax will result in errors unless transpiled or configured with a CJS-ESM interoperability solution. Always use `require` for version 0.6.0.","wrong":"import unirest from 'unirest';","symbol":"unirest","correct":"const unirest = require('unirest');"},{"note":"For version 0.6.0, Unirest operates purely on a callback-based API via the `.end()` method. Promise-based `.then()` chaining was introduced in later versions (0.9.0 onwards) and is not available in 0.6.0.","wrong":"unirest.post(...).then(response => ...);","symbol":"Request (chained methods)","correct":"unirest.post('http://example.com').headers({...}).send({...}).end(callback);"},{"note":"This package does not ship with official TypeScript definition files. Using `unirest` in a TypeScript project requires manual type declarations or relying on potentially outdated `@types/unirest` if available. Given the project's abandoned status, community types are unlikely to be well-maintained.","wrong":"import type { Unirest } from 'unirest';","symbol":"TypeScript types","correct":"(No native types)"}],"quickstart":{"code":"const unirest = require('unirest');\n\n// Example POST request using the callback-based API (typical for v0.6.0)\nunirest.post('http://mockbin.com/request')\n  .headers({'Accept': 'application/json', 'Content-Type': 'application/json'})\n  .send({ \"parameter\": 23, \"foo\": \"bar\" })\n  .end(function (response) {\n    if (response.error) {\n      console.error('Request failed:', response.error);\n      // Log detailed error information for debugging\n      if (response.error.body) console.error('Error Body:', response.error.body);\n      if (response.error.status) console.error('Error Status:', response.error.status);\n    } else {\n      console.log('Request successful (callback style)!');\n      console.log('Status:', response.status);\n      console.log('Body:', response.body);\n    }\n  });\n\n// Example GET request with direct callback argument (another common pattern in v0.6.0)\nunirest.get('http://mockbin.com/status/200', function (response) {\n  if (response.error) {\n    console.error('GET Request failed:', response.error);\n  } else {\n    console.log('GET request successful (direct callback)!');\n    console.log('Status:', response.status);\n  }\n});","lang":"javascript","description":"This quickstart demonstrates how to make both POST and GET HTTP requests using Unirest 0.6.0's callback-based API. It includes basic error handling and logging of the response status and body."},"warnings":[{"fix":"It is strongly recommended to migrate to an actively maintained HTTP client library such as `axios`, `node-fetch`, or `undici`. Evaluate the security implications carefully before using unmaintained software in production.","message":"The `unirest` library has been abandoned since approximately 2017 and is no longer maintained. This creates significant security risks as any discovered vulnerabilities will not be patched, and it lacks updates for new features, bug fixes, or compatibility with newer Node.js versions.","severity":"breaking","affected_versions":">=0.6.0"},{"fix":"Refactor your code to exclusively use the callback pattern with `.end(function(response){...})`. If Promise-based syntax is required, you must either upgrade to a much newer (and still unmaintained) version of `unirest` (v0.9.0+) or, preferably, migrate to a modern HTTP client library.","message":"Version 0.6.0 of `unirest` does not support Promises (e.g., `.then()`, `async/await`) for asynchronous operations. Its API is strictly callback-based, requiring the `.end(callback)` method to send requests and handle responses. The README excerpt incorrectly suggests Promise support for this version.","severity":"breaking","affected_versions":"0.6.0"},{"fix":"Always use the CommonJS `require()` syntax: `const unirest = require('unirest');`. If your project is primarily ESM, consider migrating to a modern HTTP client that natively supports ES modules.","message":"Being an older library, `unirest` (v0.6.0) is a CommonJS-only package. Attempting to import it using ES module `import` syntax (`import unirest from 'unirest';`) in an ES module context will result in runtime errors like `ReferenceError: require is not defined`.","severity":"gotcha","affected_versions":">=0.6.0"},{"fix":"Install `@types/unirest` if a community-maintained version exists and is compatible. Otherwise, create a `declarations.d.ts` file in your project (e.g., `declare module 'unirest';`) to provide minimal typing, or create more comprehensive types yourself. For a better long-term solution, migrate to a modern, TypeScript-friendly HTTP client.","message":"The `unirest` package does not ship with official TypeScript definition files. Using it in a TypeScript project for version 0.6.0 will lead to type errors unless manual type declarations are provided or an external `@types/unirest` package is used (which is likely unmaintained).","severity":"gotcha","affected_versions":">=0.6.0"}],"env_vars":null,"last_verified":"2026-04-22T00:00:00.000Z","next_check":"2026-07-21T00:00:00.000Z","problems":[{"fix":"Ensure your file is a CommonJS module (`.js` extension, no `\"type\": \"module\"` in `package.json`, or explicitly using a CJS loader). If in an ESM project, use a transpiler to handle `require` or, ideally, migrate to a modern HTTP client.","cause":"Attempting to use the CommonJS `require()` function in a file or project configured as an ES module.","error":"ReferenceError: require is not defined"},{"fix":"Refactor your request to use the callback pattern with the `.end()` method, for example: `unirest.post(...).end(function(response){...});`. Promise support was added in Unirest v0.9.0.","cause":"Attempting to use Promise-based `.then()` chaining with `unirest` version 0.6.0, which only supports callback-based asynchronous operations.","error":"TypeError: unirest.post(...).then is not a function"},{"fix":"Ensure the package is installed by running `npm install unirest` in your project's root directory. Verify that `node_modules` is present and accessible, and `unirest` is listed in `package.json`.","cause":"The `unirest` package was not installed in the project, or Node.js cannot resolve the module path.","error":"Error: Cannot find module 'unirest'"}],"ecosystem":"npm"}