Registry / devops / request-modern

request-modern

JSON →
library0.1.0jsnpmunverified

request-modern (v0.1.0) is a Fetch-backed replacement for the deprecated request package, providing callback and promise APIs for HTTP requests. It targets Node.js >=18, is zero-dependency, and ships TypeScript types. Key differentiators: no external dependencies, modern Response objects, and migration-friendly APIs like get, post, request.json and request.text. Released as an independent project with no affiliation to original maintainers.

npm install request-modern
INSTALL
IMPORT
SIG · REQUEST-MODERN
R
request-modern
devopsjavascriptv0.1.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

request (default import)
import request from 'request-modern'
const request = require('request-modern')
Package is ESM-only due to Node >=18 requirement; CommonJS require() will fail.
get
import { get } from 'request-modern'
const { get } = require('request-modern')
Named exports are ESM; use import destructuring.
request.json
import request from 'request-modern'; request.json('url')
import { json } from 'request-modern'
json is a method on the default export, not a named export.

Demonstrates callback, promise, and helper methods (json) for HTTP requests.

import request, { get, post } from 'request-modern'; import { writeFile } from 'node:fs/promises'; const API = process.env.API_URL ?? 'https://jsonplaceholder.typicode.com'; // Callback style request(`${API}/todos/1`, (error, response, body) => { if (error) console.error(error); else console.log('status:', response.statusCode, 'body:', body); }); // Promise style with async/await async function fetchData() { const res = await get(`${API}/todos/1`); console.log('GET status:', res.status); const text = await res.text(); console.log('Body text:', text.slice(0, 50)); } fetchData(); // Using request.json() const data = await request.json(`${API}/todos/1`); console.log('JSON data:', data); await writeFile('data.json', JSON.stringify(data, null, 2));
Debug
Known issues
breakingNode.js >=18 required; using older versions will cause SyntaxError because package is ESM-only.
fix
Upgrade Node.js to >=18 or use a bundler that can handle ESM.
affects: >=0.0.0
breakingResponse objects are native Fetch API Response, not the IncomingMessage from request. Status code is .status instead of .statusCode.
fix
Use response.status, response.headers, and response.text()/json() instead of response.statusCode, response.headers, and response.body.
affects: >=0.0.0
deprecatedThe request package is deprecated; request-modern is a separate project not affiliated with the original.
fix
No fix needed, but be aware of differences in API and behavior.
affects: >=0.0.0
gotchaMethods like request.json return parsed JSON directly, not Response objects. Do not call .json() on the result.
fix
Use await request.json(url) directly for parsed JSON; use await request(url) and then .json() on the Response for full response access.
affects: >=0.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM
Using require() to import an ESM-only package in a CommonJS module or Node.js <18.
fix
Switch to import syntax or use dynamic import: const request = await import('request-modern'); Also ensure Node.js >=18.
TypeError: response.statusCode is undefined
Accessing .statusCode on a Fetch Response object, which has .status instead.
fix
Replace response.statusCode with response.status.
TypeError: response.body is not a string
Accessing .body directly on a Fetch Response object, which is a ReadableStream, not a string.
fix
Use await response.text() or await response.json() to consume the body.
Upgrade
Version history
0.1.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
request-modern — npm install request-modern · libregistry