Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
@devmoods/fetch
Advanced tools
JSON-friendly wrapper around the Fetch API with timeouts and automatic retries
JSON-friendly wrapper around the Fetch API Fetch API with timeouts and automatic retries
npm install @devmoods/fetch
response.jsonData
- no need to await response.json()
fetch
instances with pre-configured options and root URLs.fetch<T>
to specify response types (no validation, so use wisely)HttpError
when status < 200
or status >= 400
(containing error.response
)X-Request-ID
to all requests. Retried requests have the same IDfetch
instanceimport { createFetch, TimeoutError } from '@devmoods/fetch';
const fetch = createFetch({
getRootUrl: () => 'http://localhost:3000/api',
timeout: 1000,
retryOn: () => error => error instanceof TimeoutError,
});
fetch.intercept({
request: request => console.log(request),
response: response => console.log(response),
});
type User = Record<string, any>;
const response = await fetch<User>('/users/1');
console.log(response.jsonData);
await fetch<User[]>('/users', {
timeout: 5000,
credentials: 'include',
retryOn: () = false
});
RetryOn
creatorUse the exported createRetryOn
to create functions you can pass to retryOn
. This utility makes it easy to limit amount of attempts, determine what errors to retry and setting a backoff strategy (e.g. linear or exponential).
import {
createFetch,
createRetryOn,
TimeoutError,
HttpError,
} from '@devmoods/fetch';
const fetch = createFetch({
getRootUrl: () => 'http://localhost:3000/api',
timeout: 20000,
retryOn: () =>
createRetryOn({
max: 5,
isRetriable: error =>
error instanceof HttpError
? error.response.status === 503
: error instanceof TimeoutError,
getDelay: n => 500 * n,
}),
});
MIT
FAQs
JSON-friendly wrapper around the Fetch API with timeouts and automatic retries
The npm package @devmoods/fetch receives a total of 77 weekly downloads. As such, @devmoods/fetch popularity was classified as not popular.
We found that @devmoods/fetch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.