![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@frui.ts/apiclient
Advanced tools
@frui.ts/apiclient
Fruits provides a simple abstraction for issuing backend calls.
Please note that you are not forced to use this library and you may make network calls from your repositories (or elsewhere) any way you want.
IApiConnector
is an abstraction for making actual HTTP requests. It provides functions such as get
, postText
or putJson
.
The default implementation FetchApiConnector
uses window.fetch
for network requests and a middleware that handles other than 2xx response status codes as errors by default.
The default middleware is called handleErrorStatusMiddleware
and throws FetchError
when the status code is other than 2xx.
If you want to use another HTTP client library such as Axios, you should implement the IApiConnector
interface with something like AxiosApiConnector
that would just translate the interface functions to Axios calls.
// creating new FetchApiConnector with default behavior
const connector = new FetchApiConnector();
// FetchApiConnector with custom fetch function
import { fetch as fetchPolyfill } from "whatwg-fetch";
const connector = new FetchApiConnector(fetchPolyfill);
// FetchApiConnector with custom middleware
function middleware(response: Response) {
if (response.status >= 500 && response.status < 600) {
throw "Server error";
} else {
return response;
}
}
const connector = new FetchApiConnector(window.fetch, middleware);
RestRequestBuilder
helps composing URLs in a fluent way. It is a stateful object that mutates its inner URL.
const builder = new RestRequestBuilder(apiConnector, "www.base.url", { });
const invoices = await builder.one("customers", 123).all("invoices").get<Invoice[]>(); // GET to www.base.url/customers/123/invoices
builder.reset();
const users = await builder.all("users").post<User[]>({ foo: "bar" }); // POST to www.base.url/users with content { foo: "bar" }
// Bearer token in the header for all requests
const requestParams: RequestInit = {
headers: { "authorization": "Bearer xxxyyyzzz" },
}
const builder = new RestRequestBuilder(apiConnector, "www.base.url", requestParams);
FAQs
Frui.ts helpers for HTTP communication
The npm package @frui.ts/apiclient receives a total of 112 weekly downloads. As such, @frui.ts/apiclient popularity was classified as not popular.
We found that @frui.ts/apiclient demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.