Registry / testing / venus-fetch

venus-fetch

JSON →
library1.1.17jsnpmunverified

venus-fetch (vFetch) is a lightweight, easy-to-use fetch wrapper for making HTTP requests in browser environments. Current stable version 1.1.17. It provides a simplified API with support for GET, POST, PUT, DELETE, and OPTIONS methods, request/response interceptors (before/after hooks), configurable timeout, automatic Content-Type handling (form-urlencoded, multipart/form-data, JSON), file upload/download support, and built-in error codes. It differentiates itself by its hook system and global error handling, though it lacks TypeScript types, ESM modules, and server-side (Node.js) support.

npm install venus-fetch
INSTALL
IMPORT
SIG · VENUS-FETCH
V
venus-fetch
testingjavascriptv1.1.17
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.

VFetch
import VFetch from 'venus-fetch'
const VFetch = require('venus-fetch')
Library exports a default function, not a CommonJS module. Use ES import only.
HttpError
import VFetch from 'venus-fetch'; const httpError = new VFetch.HttpError({...})
import { HttpError } from 'venus-fetch'
HttpError is a static property on the default import, not a named export.
HTTP_ERROR_MAP
import VFetch from 'venus-fetch'; const errorMap = VFetch.HTTP_ERROR_MAP
import { HTTP_ERROR_MAP } from 'venus-fetch'
HTTP_ERROR_MAP is a static property on the default import.

Creates an HTTP client with base URL '/api', hooks, and timeout, then makes a GET request.

import VFetch from 'venus-fetch' const http = VFetch({ conf: { credentials: 'include', baseUrl: '/api', headers: { Accept: 'application/json' } }, before: [([url, opt]) => console.log('hook1', url, opt)], after: [(rsp) => console.log('after hook', rsp)], timeout: 5000, }) http.get('users', { limit: 10 }) .then(rsp => console.log(rsp)) .catch(err => console.error(err))
Debug
Known issues
gotchaThe library does not support Node.js (no built-in fetch in older versions) and is intended only for browser environments.
fix
Use a different library like 'node-fetch' or 'axios' for server-side code.
affects: >=1.0.0
gotchaThe default import is a factory function, not a class. Calling 'new VFetch()' will throw an error.
fix
Use VFetch(config) without 'new'.
affects: >=1.0.0
gotchaThe 'conf.baseUrl' must not have a trailing slash, otherwise URL construction may produce double slashes.
fix
Ensure baseUrl does not end with '/'.
affects: >=1.0.0
deprecatedThe 'setErrorHook' method is deprecated; use 'error' config option instead.
fix
Pass error handler via VFetch({ error: (e) => ... })
affects: >=1.1.0
Errors
Common errors & fixes
Uncaught TypeError: VFetch is not a constructor
Using 'new VFetch()' instead of 'VFetch()'
fix
Remove 'new': const http = VFetch(opt)
Uncaught TypeError: Cannot read properties of undefined (reading 'then')
Calling http.get() before initializing http or incorrect import
fix
Ensure VFetch is called: const http = VFetch(config); http.get(...)
Uncaught ReferenceError: VFetch is not defined
Using script tag without loading the library or incorrect import path
fix
Include the script: <script src='../dist/vFetch.js'></script> or correct import path
Upgrade
Version history
1.1.17latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
venus-fetch — npm install venus-fetch · libregistry