A Node.js package (v2.1.2, last updated 2019) for fetching local or remote files and returning them as base64-encoded strings with optional MIME type prefixes. Useful for inlining assets like images or fonts into HTML/CSS. Provides three functions: `local`, `remote`, and `auto` for path detection. No dependencies, simple API, but no longer actively maintained. Alternative to data URIs with manual encoding.
npm install fetch-base64No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to require the package and use local, remote, and auto functions to fetch files and get base64 encoded data with MIME type.
Always use data[1] if you need a data URI.
Pass custom headers via the options object: fetch.remote({ url, headers: { Authorization: '...' } })Use explicit local() or remote() calls instead of auto() when mixing types.
Consider alternatives like 'request' (deprecated) or using native fetch with Buffer encoding.
Use require('fetch-base64') instead of import.Add a .catch handler to log the error: promise.catch(err => console.error(err)).
Ensure all path arguments are strings.
No dependency data recorded yet.