Registry / devops / uberfetch

uberfetch

JSON →
library1.0.1jsnpmunverified

uberfetch is a thin convenience wrapper around the native Fetch API that sets JSON as the default format and converts HTTP error responses (non-2xx status codes) into rejected promises. Current stable version is 1.0.1. The library simplifies common fetch patterns: automatic JSON stringification and parsing, method-specific helpers (get, post, put, patch, delete), and a RequestError class for typed error handling. It relies on the browser's built-in fetch or a polyfill like github/fetch. Minimal—no complex configuration, ideal for projects that want a lightweight alternative to Axios or Ky.

npm install uberfetch
INSTALL
IMPORT
SIG · UBERFETCH
U
uberfetch
devopsjavascriptv1.0.1
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.

default
import uberfetch from 'uberfetch'
const uberfetch = require('uberfetch')
Package is ESM-only (no CommonJS export). Use default import or dynamic import.
uberfetch.get
import uberfetch from 'uberfetch'; uberfetch.get('/url')
No separate export for get/post; they are methods on the default import.
uberfetch.RequestError
import uberfetch from 'uberfetch'; const err = new uberfetch.RequestError(response)
import { RequestError } from 'uberfetch'
RequestError is a property on the default export, not a named export.

Shows GET and POST requests with JSON handling and typed error catching using uberfetch.RequestError.

import uberfetch from 'uberfetch'; // GET JSON uberfetch('https://api.example.com/items/1') .then(res => res.json()) .then(data => console.log(data)); // POST JSON uberfetch.post('https://api.example.com/items', { body: { name: 'New Item', price: 9.99 } }) .then(res => res.json()) .then(console.log); // Handle HTTP errors uberfetch.get('/not-found') .catch(err => { if (err instanceof uberfetch.RequestError) { console.error('HTTP Error:', err.status, err.response); } });
Debug
Known issues
gotchauberfetch only works in browsers or environments with fetch (Node.js requires polyfill)
fix
Install a fetch polyfill like 'whatwg-fetch' or use 'node-fetch' and polyfill globally.
affects: >=0.0.0
deprecatedThe package has not been updated since 2017 and may not support newer standards (e.g. abort controllers, streaming)
fix
Consider migrating to modern alternatives like Ky or plain fetch.
affects: <=1.0.1
gotchauberfetch treats Content-Type headers as JSON by default when no type is specified; non-JSON bodies may be stringified unexpectedly
fix
Explicitly set 'contentType' option to override serialization behavior.
affects: >=0.0.0
gotchauberfetch converts only non-2xx responses (status >= 400) to rejections; 3xx redirects are followed by fetch
fix
To handle redirects manually, use 'fetch' directly with redirect: 'manual'.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: uberfetch is not a function
Using 'require' on an ESM-only package
fix
Use 'import uberfetch from 'uberfetch'' instead of 'require'.
ReferenceError: fetch is not defined
Running in Node.js without a fetch polyfill
fix
Install 'whatwg-fetch' or 'node-fetch' and polyfill: global.fetch = require('node-fetch').
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
whatwg-fetchoptionalProvides the fetch API in environments that lack it (older browsers)
Agent activity
5 hits · last 30 days
node
4
Amazon
1
Resources
uberfetch — npm install uberfetch · libregistry