Registry / testing / trae
library1.4.2jsnpmunverified

Minimalistic HTTP client for the browser, based on the Fetch API. It provides a clean, promise-based interface for making HTTP requests (GET, POST, PUT, PATCH, DELETE, HEAD) with support for query parameters, custom headers, body type parsing (json, text, blob, etc.), mode and credentials configuration, and middleware. Current stable version is 1.4.2. It is designed to be future-proof with native Fetch, but requires a polyfill for older browsers. Lightweight alternative to axios with no external dependencies.

npm install trae
INSTALL
IMPORT
SIG · TRAE
T
trae
testingjavascriptv1.4.2
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 trae from 'trae'
import { trae } from 'trae'
Default import; named export does not exist.
create
import trae, { create } from 'trae'
const { create } = require('trae')
create is a named export, but trae is the default. CommonJS destructure works too.
trae.get
trae.get(url, config)
trae.get(url, body)
GET requests do not accept a body parameter; use config.params instead.

Demonstrates basic GET and POST requests using trae with promises.

import trae from 'trae'; // GET request const url = 'https://api.example.com/data'; trae.get(url, { params: { key: process.env.API_KEY ?? '' } }) .then(response => { console.log(response.data); }) .catch(err => { console.error(err); }); // POST request const body = { title: 'foo', content: 'bar' }; trae.post('https://api.example.com/posts', body) .then(() => console.log('Success')) .catch(err => console.error(err));
Debug
Known issues
breakingv1.0.0 changed response structure: response.data instead of response.body
fix
Use response.data instead of response.body for parsed response body.
affects: >=0.x <1.0.0
deprecatedbodyType: 'raw' is deprecated since v1.2.0; use bodyType: undefined or omit to get raw response
fix
Remove bodyType or set to undefined if you want raw response.
affects: >=1.2.0
gotchaBrowser-only: trae relies on global fetch which is not available in Node.js <18 or older browsers
fix
Use a fetch polyfill (e.g., 'whatwg-fetch') for Node.js or older browsers.
affects: all
Errors
Common errors & fixes
TypeError: Cannot read property 'then' of undefined
Using trae.get or similar without passing url as string, e.g., passing undefined or object.
fix
Ensure the first argument to HTTP method is a valid URL string.
Uncaught TypeError: Failed to fetch
CORS issue or network error when making cross-origin request without proper configuration.
fix
Set config.mode to 'cors' or ensure server supports CORS. Also check for HTTPS vs HTTP mismatch.
TypeError: trae is not a function
Trying to call trae as a function instead of using trae.get etc., or incorrectly importing.
fix
Use trae.get or import trae correctly: import trae from 'trae'
Upgrade
Version history
1.4.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
9 hits · last 30 days
node
8
Amazon
1
Resources
packagetrae
trae — npm install trae · libregistry