Registry / devops / frest
library1.2.0jsnpmunverified

Frest is a browser REST client that wraps the Fetch API with an XMLHttpRequest fallback for environments where Fetch is unavailable or for file upload/download with progress events. Version 1.2.0 is current and stable. Key differentiators include interceptor support (before request, after response, and error), CRUD aliases, TypeScript definitions, and UMD builds for direct script tag usage. It is a lightweight alternative to axios with built-in XHR fallback.

npm install frest
INSTALL
IMPORT
SIG · FREST
F
frest
devopsjavascriptv1.2.0
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 (frest)
import frest from 'frest'
const frest = require('frest')
ESM default import. For CommonJS, use require('frest').default.
Frest (class)
import { Frest } from 'frest'
import Frest from 'frest'
Named export of the Frest class. Not needed if using default instance.
FrestError
import { FrestError } from 'frest'
import FrestError from 'frest'
Named export for error type checking.

Shows how to make a GET request with frest, handle the response, and parse JSON.

import frest from 'frest'; async function main() { const res = await frest.get('https://api.example.com/data', { headers: { 'Authorization': `Bearer ${process.env.API_KEY ?? ''}` } }); if (res.origin.ok) { const body = await res.origin.json(); console.log(body); } else { throw new Error('Request failed'); } } main().catch(err => console.error(err));
Debug
Known issues
gotchaBy default, without interceptors, the body is undefined. You need to call res.origin.json() or similar to parse the response body.
fix
Use res.origin.json() or add a response interceptor to parse automatically.
affects: >=1.0.0
gotchaThe create() method expects either a string (base URL) or a config object. Passing a string does not merge with default headers; use an object for custom headers.
fix
Use frest.create({ base: '...', headers: ... }) to set custom headers.
affects: >=1.0.0
gotchaThe download() and upload() methods require XMLHttpRequest fallback; they will fail if Fetch is forced and the browser does not support progress events.
fix
Ensure XMLHttpRequest is available or use polyfills.
affects: >=1.0.0
breakingVersion 1.0.0 changed the default export from a class to a pre-configured instance. Code using frest as a constructor will break.
fix
Use frest.create() to get a new instance instead of new frest()
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: frest is not a constructor
Using 'new frest()' with version 1.0.0+ where default export is a pre-configured instance.
fix
Use frest.create() to create a new instance.
Cannot find module 'frest'
Package not installed or import path incorrect.
fix
Run 'npm install frest' and ensure import is correct: import frest from 'frest'
Property 'origin' does not exist on type 'Response'
TypeScript type mismatch: the response object is a custom FrestResponse, not the native Fetch Response.
fix
Access the native response via res.origin to use standard Fetch properties.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
packagefrest
frest — npm install frest · libregistry