Registry / devops / fetch-media

fetch-media

JSON →
library3.3.4jsnpmunverified

Utility for fetching media resources with automatic encoding/decoding. v3.3.4, TypeScript-first, actively maintained. Automatically handles JSON, text, binary, FormData, and URL-encoded request/response bodies. Parses structured errors. Known incompatibility with Node 18+ native fetch due to Response class differences. Requires manual installation of @ungap/url-search-params for React Native. Differentiator: intelligent media type handling versus raw fetch or other wrappers.

npm install fetch-media
INSTALL
IMPORT
SIG · FETCH-MEDIA
F
fetch-media
devopsjavascriptv3.3.4
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.

fetchMedia
import { fetchMedia } from 'fetch-media'
import fetchMedia from 'fetch-media'
fetchMedia is a named export, not default.
fetchMediaWrapped
import { fetchMediaWrapped } from 'fetch-media'
Returns full Response object.
MediaOptions
import type { MediaOptions } from 'fetch-media'
import { MediaOptions } from 'fetch-media'
MediaOptions is a TypeScript type; import as type for proper tree-shaking.

Shows basic usage of fetchMedia with automatic JSON encoding/decoding.

import { fetchMedia } from 'fetch-media'; const url = process.env.API_URL ?? 'https://example.org'; fetchMedia(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: { message: 'hello' }, }) .then((response) => { console.log(response); // automatically decoded as JSON }) .catch((error) => { console.error('Fetch failed:', error); });
Debug
Known issues
gotchaDoes not work flawlessly with Node 18+ native fetch because their Response class is implemented differently.
fix
Use a polyfill like node-fetch or undici that provides a compatible Response class.
affects: >=3.0.0
gotchaReact Native users must install @ungap/url-search-params as a separate dependency.
fix
Run: yarn add @ungap/url-search-params
affects: >=3.0.0
gotchaLibraries that change the global fetch may cause unexpected behavior.
fix
Ensure the global fetch is not overridden or test compatibility.
affects: >=3.0.0
Errors
Common errors & fixes
Cannot find module '@ungap/url-search-params'
Missing dependency when using in React Native without bundling.
fix
Install @ungap/url-search-params: npm install @ungap/url-search-params
fetchMedia is not a function
Trying to use default import instead of named import.
fix
Use: import { fetchMedia } from 'fetch-media'
TypeError: Failed to parse URL from ...
Node 18+ fetch URL validation is stricter.
fix
Provide a properly formatted URL string.
Upgrade
Version history
3.3.4latest on npm
Audit
Dependencies
@ungap/url-search-paramsoptionalRequired when using in React Native unbundled source mode.
Agent activity
2 hits · last 30 days
node
2
Resources
fetch-media — npm install fetch-media · libregistry