A lightweight wrapper around the Fetch API provided as a class, supporting JSON/text transforms, base URLs, automatic rejection on non-OK status, and typed HTTP methods (get, post, put, patch, delete). Version 10.0.0 requires Node >=24.16.0 and ships TypeScript types. It differentiates itself by offering a simple, class-based interface with optional transform and reject options, making it easy to extend for custom API clients.
npm install rpc-requestNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create a Fetch client with base URL, JSON transform, and rejection on non-OK status, then make a typed GET request.
Upgrade Node.js to version 24.16.0 or later. Alternatively, use an older version of rpc-request (9.x or below) which supports lower Node versions.
Explicitly set transform: 'json' or 'text' in Fetch constructor options.
Always set a transform if you want automatic error handling or response parsing.
Use `new URL('http://example.com/')` instead of a plain string.Use ES module import syntax: `import { Fetch } from 'rpc-request'`Use `new Fetch(options)` instead of `Fetch(options)`.
Use `new URL('http://example.com')` for the `base_url` option.Handle the error with try/catch, or set `reject: false` to return the response without throwing.
Ensure base_url ends with a trailing slash if paths are relative, or use absolute URLs in path.
No dependency data recorded yet.