Registry / http-networking / reqwest

reqwest

JSON →
library0.0.0jsnpmunverified

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.

npm install reqwest
INSTALL
IMPORT
SIG · REQWEST
R
reqwest
http-networkingjavascriptv0.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

reqwest
const reqwest = require('reqwest')
import reqwest from 'reqwest'
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.

Demonstrates `reqwest` usage for simple GET requests with callbacks, POST requests with JSON data and promises, and a placeholder for JSONP.

const reqwest = require('reqwest'); // Example 1: Basic GET request with callback reqwest('https://jsonplaceholder.typicode.com/posts/1', function (resp) { console.log('GET with callback response:', resp); }); // Example 2: POST request with JSON data and Promises reqwest({ url: 'https://jsonplaceholder.typicode.com/posts', method: 'post', type: 'json', contentType: 'application/json', data: JSON.stringify({ title: 'foo', body: 'bar', userId: 1 }), headers: { 'X-Custom-Header': 'MyValue' } }) .then(function (resp) { console.log('POST with Promise success:', resp); }) .fail(function (err, msg) { console.error('POST with Promise error:', err, msg); }) .always(function () { console.log('POST request completed (always).'); }); // Example 3: JSONP request (assuming a JSONP endpoint like 'https://example.com/data.jsonp?callback=?') // For demonstration, this won't run without a live JSONP service. reqwest({ url: 'https://httpbin.org/jsonp?callback=?', // Using a placeholder for demonstration type: 'jsonp', jsonpCallback: 'callback', success: function (resp) { console.log('JSONP request successful:', resp); }, error: function (err) { console.error('JSONP request failed:', err); } });
Debug
Known issues
breakingThe `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.
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.
affects: >=2.0.5
deprecated`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.
fix
Refactor asynchronous operations to use native `Promise` constructors, `async/await`, or the promise interface provided by a modern HTTP client.
affects: >=1.0.0
gotchaWhile `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.
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.
affects: >=1.0.0
gotchaThere 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.
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`).
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: require is not a function
Attempting to import or use `reqwest` via CommonJS `require()` syntax within an ECMAScript Module (ESM) file or environment.
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.
ReferenceError: XMLHttpRequest is not defined
Using `reqwest` in a Node.js environment without the `xhr2` package installed or properly configured to polyfill the `XMLHttpRequest` object.
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.
Upgrade
Version history
0.0.0latest on npm
Audit
Dependencies
xhr2optionalOptional peer dependency required for enabling `reqwest` to function in Node.js environments by providing an XMLHttpRequest polyfill.
Agent activity
9 hits · last 30 days
node
8
Resources
reqwest — npm install reqwest · libregistry