{"id":17351,"library":"reqwest","title":"Simple Asynchronous HTTP Client","description":"Reqwest is a browser-focused JavaScript library designed for making asynchronous HTTP requests, offering support for XMLHttpRequest, JSONP, CORS, and the CommonJS Promises/A specification. While it provided isomorphic capabilities allowing use in Node.js via the `xhr2` peer dependency, its primary intention and optimization were for client-side AJAX operations. The package is currently at version 2.0.5 and has not received any updates since August 2015. This effectively marks it as an abandoned project. Its Promise implementation adheres to an older specification (Promises/A), which may not be fully compatible with the ES2015+ Promises/A+ standard or modern `async/await` patterns. For contemporary JavaScript development, the native Fetch API or actively maintained alternatives like `axios` are generally preferred due to `reqwest`'s lack of ongoing support and potential compatibility issues with modern environments and security practices.","status":"abandoned","version":"2.0.5","language":"javascript","source_language":"en","source_url":"https://github.com/ded/reqwest","tags":["javascript","ender","ajax","xhr","connection","web 2.0","async","sync"],"install":[{"cmd":"npm install reqwest","lang":"bash","label":"npm"},{"cmd":"yarn add reqwest","lang":"bash","label":"yarn"},{"cmd":"pnpm add reqwest","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Optional peer dependency required for enabling `reqwest` to function in Node.js environments by providing an XMLHttpRequest polyfill.","package":"xhr2","optional":true}],"imports":[{"note":"Reqwest is a CommonJS-only module. Direct ES module `import` syntax will not work without a build step or specific Node.js loader configurations. Even with `import { default as reqwest } from 'reqwest'`, it's not designed for ESM.","wrong":"import reqwest from 'reqwest'","symbol":"reqwest","correct":"const reqwest = require('reqwest')"}],"quickstart":{"code":"const reqwest = require('reqwest');\n\n// Example 1: Basic GET request with callback\nreqwest('https://jsonplaceholder.typicode.com/posts/1', function (resp) {\n  console.log('GET with callback response:', resp);\n});\n\n// Example 2: POST request with JSON data and Promises\nreqwest({\n    url: 'https://jsonplaceholder.typicode.com/posts',\n    method: 'post',\n    type: 'json',\n    contentType: 'application/json',\n    data: JSON.stringify({ title: 'foo', body: 'bar', userId: 1 }),\n    headers: {\n        'X-Custom-Header': 'MyValue'\n    }\n})\n.then(function (resp) {\n  console.log('POST with Promise success:', resp);\n})\n.fail(function (err, msg) {\n  console.error('POST with Promise error:', err, msg);\n})\n.always(function () {\n  console.log('POST request completed (always).');\n});\n\n// Example 3: JSONP request (assuming a JSONP endpoint like 'https://example.com/data.jsonp?callback=?')\n// For demonstration, this won't run without a live JSONP service.\nreqwest({\n    url: 'https://httpbin.org/jsonp?callback=?', // Using a placeholder for demonstration\n    type: 'jsonp',\n    jsonpCallback: 'callback',\n    success: function (resp) {\n        console.log('JSONP request successful:', resp);\n    },\n    error: function (err) {\n        console.error('JSONP request failed:', err);\n    }\n});","lang":"javascript","description":"Demonstrates `reqwest` usage for simple GET requests with callbacks, POST requests with JSON data and promises, and a placeholder for JSONP."},"warnings":[{"fix":"Migrate immediately to a modern, actively maintained HTTP client library such as `axios`, `ky`, or the native `fetch` API for all new and existing projects.","message":"The `reqwest` library is abandoned and has not received any updates since August 2015. It is likely incompatible with modern JavaScript runtimes, browsers, and security standards, and may contain unpatched vulnerabilities or unexpected behavior with newer language features.","severity":"breaking","affected_versions":">=2.0.5"},{"fix":"Refactor asynchronous operations to use native `Promise` constructors, `async/await`, or the promise interface provided by a modern HTTP client.","message":"`reqwest` implements the older CommonJS Promises/A specification, which is not fully compatible with the ES2015+ Promises/A+ standard. This can lead to subtle bugs or integration issues when mixing `reqwest` with modern JavaScript's native Promises or `async/await` syntax.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Do not use `reqwest` in Node.js environments. Utilize Node.js's built-in `http`/`https` modules, `node-fetch`, or `axios` for server-side HTTP requests.","message":"While `reqwest` claims isomorphism and can technically run in Node.js with the `xhr2` polyfill, its `README` explicitly discourages this for robust Node.js solutions, recommending `mikeal/request` (which is also now deprecated). It lacks native Node.js HTTP client features and integrations.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Switch to an HTTP client that provides robust first-party or community-maintained TypeScript support (e.g., `axios`, `ky`, `fetch` with `@types/node-fetch`).","message":"There are no official or well-maintained community TypeScript type definitions for `reqwest`. Using this library in a TypeScript project will result in a lack of type safety and a poor developer experience, requiring manual type declarations or `@ts-ignore` directives.","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":"Ensure your project is configured to use CommonJS modules for files that interact with `reqwest` (e.g., by ensuring 'type': 'module' is not present in the nearest `package.json`, or by using a build tool that correctly bundles CommonJS modules for ESM consumption). Alternatively, consider migrating to a modern, ESM-compatible HTTP client.","cause":"Attempting to import or use `reqwest` via CommonJS `require()` syntax within an ECMAScript Module (ESM) file or environment.","error":"TypeError: require is not a function"},{"fix":"Install the `xhr2` package (`npm install xhr2`). Note that even with `xhr2`, `reqwest` is not recommended for Node.js, and this setup may still lead to other compatibility issues.","cause":"Using `reqwest` in a Node.js environment without the `xhr2` package installed or properly configured to polyfill the `XMLHttpRequest` object.","error":"ReferenceError: XMLHttpRequest is not defined"}],"ecosystem":"npm","meta_description":null}