
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@uxland/fetch-client
Advanced tools
Build Status | Statements | Branches | Functions | Lines |
---|---|---|---|---|
npm i @uxland/fetch-client
Set Base URL
All relative fetch will use provided url as its own base URL. If using absolute uri when fetching, this will not be taken into account.
import { setBaseUrl } from "@uxland/fetch-client";
setBaseUrl("http://localhost");
Register response handlers
Register a response handler to manipulate result.
import { registerResponseHandler } from "@uxland/fetch-client";
registerResponseHandler((response) => JSON.stringify(response));
Change fetch client configuration
Change configuration globally. All fetch requests will use this configuration.
import { configure } from '@uxland/fetch-client';
configure({mode: 'no-cors',{ headers: {authorization: 'Bearer <token>' }}});
Change fetch client headers
Change headers globally. All fetch requests will use specified headers.
import { setHeaders } from "@uxland/fetch-client";
setHeaders({ authorization: "Bearer <token>" });
Delete specific header
Remove a header from global headers using provided id.
import { removeHeader } from "@uxland/fetch-client";
removeHeader("authorization");
Reset fetch client headers
Reset global headers to default.
import { resetHeaders } from "@uxland/fetch-client";
resetHeaders();
import { doFetch } from "@uxland/fetch-client";
const response = doFetch("/dummy", { mode: "no-cors" }, { foo: "bar" })
.then((r) => r)
.catch((e) => e);
In addition, fetchClient also publishes (via @uxland/event-aggregator
) two events INVALID_CREDENTIALS_EVENT and INVALID_REQUEST_EVENT when credentials are invalid or request has failed.
FAQs
Fetch Client
The npm package @uxland/fetch-client receives a total of 14 weekly downloads. As such, @uxland/fetch-client popularity was classified as not popular.
We found that @uxland/fetch-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.