Registry / devops / rest-request

rest-request

JSON →
library1.0.12jsnpmunverified

A small Node.js HTTP client for making REST requests with promise-based responses. Version 1.0.12 provides a simple Request constructor that takes a base path and optional default headers. Supports GET, POST, PUT, DELETE methods with URL parameter substitution (both :param and {param} syntax) and automatic query string building for unused parameters. Different from full-featured clients like Axios or Got, it focuses on minimalism with no external dependencies. Stable but not actively maintained; last update was in 2017.

npm install rest-request
INSTALL
IMPORT
SIG · REST-REQUEST
R
rest-request
devopsjavascriptv1.0.12
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
const Request = require('rest-request');
const { Request } = require('rest-request');
The module exports a constructor function directly (CommonJS default export). Named destructuring will fail.
rest-request (ESM)
import Request from 'rest-request';
import { Request } from 'rest-request';
ESM default import works only if the package provides ESM support (check package.json). As of v1.0.12, it's purely CJS.
Request type (TypeScript)
import Request from 'rest-request'; const api: InstanceType<typeof Request> = new Request('http://example.com');
const api: Request = new Request('http://example.com');
Package does not ship TypeScript definitions. Use with @types/rest-request or declare own types.

Shows how to create a Request instance, make a GET request, and handle the promise result with async/await.

const Request = require('rest-request'); async function main() { const api = new Request('https://jsonplaceholder.typicode.com'); try { const data = await api.get('posts/1'); console.log('User ID:', data.userId); console.log('Title:', data.title); } catch (error) { console.error('Error:', error.message); } } main();
Debug
Known issues
deprecatedPackage has not been updated since 2017. No ES module support, no TypeScript types, relies on 'request' dependency internally (deprecated).
fix
Consider migrating to a modern HTTP client like 'got' or 'axios'.
affects: >=1.0.0
gotchaThe 'headers' option in constructor sets default headers but they are shallow merged with per-request headers; per-request headers override defaults entirely (not deep merge).
fix
If you need to combine headers, manually handle merging.
affects: >=0.0.0
gotchaPath parameters with both :param and {param} syntax are supported but not interchangeable in the same path; must be consistent.
fix
Use either :param or {param} throughout the path string.
affects: >=0.0.0
breakingVersion 1.0.0 changed from callback-based to promise-based responses. Code using older versions with callbacks will break.
fix
Upgrade to >=1.0.0 and use .then()/.catch() or async/await instead of callbacks.
affects: <1.0.0
Errors
Common errors & fixes
Cannot find module 'rest-request'
Package not installed or imported with wrong path.
fix
Run 'npm install rest-request' and ensure require('rest-request') is correct.
TypeError: restAPI.get is not a function
Using destructuring const { get } = require('rest-request') instead of creating an instance.
fix
Use 'const Request = require('rest-request'); const restAPI = new Request(baseUrl);'
request is not defined
Attempting to use 'request' as a standalone function; it's only available on instances.
fix
Create a new Request instance with a base URL first, then call methods on it.
Upgrade
Version history
1.0.12latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
8
Resources
rest-request — npm install rest-request · libregistry