Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@axios-use/react

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@axios-use/react - npm Package Compare versions

Comparing version 6.3.0 to 6.4.0-alpha.0

esm/cachettl.d.ts

25

esm/request.d.ts

@@ -8,15 +8,14 @@ import type { AxiosRequestConfig, AxiosResponse, AxiosError, Canceler } from "axios";

export declare type Request<T = any, D = any> = (...args: any[]) => Resource<T, D>;
export declare type Payload<TRequest extends Request> = ReturnType<TRequest>["payload"];
export declare type CData<TRequest extends Request> = ReturnType<TRequest>["data"];
export interface RequestFactory<TRequest extends Request> {
(...args: Parameters<TRequest>): {
export declare type Payload<T extends Request> = ReturnType<T>["payload"];
export declare type BodyData<T extends Request> = ReturnType<T>["data"];
/** @deprecated No longer use. Use `BodyData` instead */
export declare type CData<T extends Request> = BodyData<T>;
export interface RequestFactory<T extends Request> {
(...args: Parameters<T>): {
cancel: Canceler;
ready: () => Promise<[
Payload<TRequest>,
AxiosResponse<Payload<TRequest>, CData<TRequest>>
]>;
ready: () => Promise<[Payload<T>, AxiosResponse<Payload<T>, BodyData<T>>]>;
};
}
export interface RequestDispatcher<TRequest extends Request> {
(...args: Parameters<TRequest>): Canceler;
export interface RequestDispatcher<T extends Request> {
(...args: Parameters<T>): Canceler;
}

@@ -30,7 +29,7 @@ export interface RequestError<T = any, D = any, E = AxiosError<T, D> | AxiosResponse<T, D>> {

}
export declare type RequestCallbackFn<TRequest extends Request> = {
onCompleted?: (data?: Payload<TRequest>, response?: AxiosResponse<CData<TRequest>>) => void;
onError?: (err?: RequestError<Payload<TRequest>, CData<TRequest>>) => void;
export declare type RequestCallbackFn<T extends Request> = {
onCompleted?: (data: Payload<T>, response: AxiosResponse<BodyData<T>>) => void;
onError?: (err?: RequestError<Payload<T>, BodyData<T>>) => void;
};
export declare function request<T, D = any>(config: AxiosRequestConfig<D>): Resource<T, D>;
export declare function createRequestError<T = any, D = any, E = AxiosError<T, D> | AxiosResponse<T, D>>(error: E): RequestError<T, D, E>;

@@ -6,13 +6,10 @@ import axios from "axios";

export function createRequestError(error) {
var _a, _b, _c;
var _a, _b, _c, _d, _e, _f, _g;
var axiosErr = error;
var axiosRes = error;
var data = ((_a = axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.response) === null || _a === void 0 ? void 0 : _a.data) || (axiosRes === null || axiosRes === void 0 ? void 0 : axiosRes.data);
var data = (_b = (_a = axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.response) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : axiosRes === null || axiosRes === void 0 ? void 0 : axiosRes.data;
var code =
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(data === null || data === void 0 ? void 0 : data.code) ||
(axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.code) ||
((_b = axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.response) === null || _b === void 0 ? void 0 : _b.status) ||
(axiosRes === null || axiosRes === void 0 ? void 0 : axiosRes.status);
var message = (axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.message) || ((_c = axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.response) === null || _c === void 0 ? void 0 : _c.statusText) || (axiosRes === null || axiosRes === void 0 ? void 0 : axiosRes.statusText);
(_f = (_d = (_c = data === null || data === void 0 ? void 0 : data.code) !== null && _c !== void 0 ? _c : axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.code) !== null && _d !== void 0 ? _d : (_e = axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.response) === null || _e === void 0 ? void 0 : _e.status) !== null && _f !== void 0 ? _f : axiosRes === null || axiosRes === void 0 ? void 0 : axiosRes.status;
var message = (axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.message) || ((_g = axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.response) === null || _g === void 0 ? void 0 : _g.statusText) || (axiosRes === null || axiosRes === void 0 ? void 0 : axiosRes.statusText);
return {

@@ -19,0 +16,0 @@ code: code,

@@ -26,3 +26,4 @@ var __assign = (this && this.__assign) || function () {

import { createCacheKey, wrapCache } from "./cache";
var cache = wrapCache(new Map());
import { _ttlcache } from "./cachettl";
var cache = wrapCache(_ttlcache);
var defaultConfig = {

@@ -29,0 +30,0 @@ cache: cache,

@@ -13,2 +13,2 @@ import type { Canceler, AxiosInstance } from "axios";

];
export declare function useRequest<TRequest extends Request>(fn: TRequest, options?: UseRequestOptions<TRequest>): UseRequestResult<TRequest>;
export declare function useRequest<T extends Request>(fn: T, options?: UseRequestOptions<T>): UseRequestResult<T>;
import type { Canceler, AxiosResponse } from "axios";
import type { Payload, CData, RequestError, Request, RequestDispatcher, RequestCallbackFn } from "./request";
import type { Payload, BodyData, RequestError, Request, RequestDispatcher, RequestCallbackFn } from "./request";
import type { RequestContextConfig } from "./requestContext";

@@ -7,7 +7,7 @@ import type { CacheKey, CacheKeyFn } from "./cache";

data?: Payload<TRequest>;
response?: AxiosResponse<CData<TRequest>>;
error?: RequestError<Payload<TRequest>, CData<TRequest>>;
response?: AxiosResponse<BodyData<TRequest>>;
error?: RequestError<Payload<TRequest>, BodyData<TRequest>>;
isLoading?: boolean;
/** @deprecated Use `response` instead */
other?: AxiosResponse<CData<TRequest>>;
other?: AxiosResponse<BodyData<TRequest>>;
};

@@ -27,3 +27,3 @@ export declare type UseResourceResult<TRequest extends Request> = [

};
export declare function useResource<TRequest extends Request>(fn: TRequest, requestParams?: Parameters<TRequest> | false, options?: UseResourceOptions<TRequest>): UseResourceResult<TRequest>;
export declare function useResource<T extends Request>(fn: T, requestParams?: Parameters<T> | false, options?: UseResourceOptions<T>): UseResourceResult<T>;
export {};

@@ -8,15 +8,14 @@ import type { AxiosRequestConfig, AxiosResponse, AxiosError, Canceler } from "axios";

export declare type Request<T = any, D = any> = (...args: any[]) => Resource<T, D>;
export declare type Payload<TRequest extends Request> = ReturnType<TRequest>["payload"];
export declare type CData<TRequest extends Request> = ReturnType<TRequest>["data"];
export interface RequestFactory<TRequest extends Request> {
(...args: Parameters<TRequest>): {
export declare type Payload<T extends Request> = ReturnType<T>["payload"];
export declare type BodyData<T extends Request> = ReturnType<T>["data"];
/** @deprecated No longer use. Use `BodyData` instead */
export declare type CData<T extends Request> = BodyData<T>;
export interface RequestFactory<T extends Request> {
(...args: Parameters<T>): {
cancel: Canceler;
ready: () => Promise<[
Payload<TRequest>,
AxiosResponse<Payload<TRequest>, CData<TRequest>>
]>;
ready: () => Promise<[Payload<T>, AxiosResponse<Payload<T>, BodyData<T>>]>;
};
}
export interface RequestDispatcher<TRequest extends Request> {
(...args: Parameters<TRequest>): Canceler;
export interface RequestDispatcher<T extends Request> {
(...args: Parameters<T>): Canceler;
}

@@ -30,7 +29,7 @@ export interface RequestError<T = any, D = any, E = AxiosError<T, D> | AxiosResponse<T, D>> {

}
export declare type RequestCallbackFn<TRequest extends Request> = {
onCompleted?: (data?: Payload<TRequest>, response?: AxiosResponse<CData<TRequest>>) => void;
onError?: (err?: RequestError<Payload<TRequest>, CData<TRequest>>) => void;
export declare type RequestCallbackFn<T extends Request> = {
onCompleted?: (data: Payload<T>, response: AxiosResponse<BodyData<T>>) => void;
onError?: (err?: RequestError<Payload<T>, BodyData<T>>) => void;
};
export declare function request<T, D = any>(config: AxiosRequestConfig<D>): Resource<T, D>;
export declare function createRequestError<T = any, D = any, E = AxiosError<T, D> | AxiosResponse<T, D>>(error: E): RequestError<T, D, E>;

@@ -13,13 +13,10 @@ "use strict";

function createRequestError(error) {
var _a, _b, _c;
var _a, _b, _c, _d, _e, _f, _g;
var axiosErr = error;
var axiosRes = error;
var data = ((_a = axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.response) === null || _a === void 0 ? void 0 : _a.data) || (axiosRes === null || axiosRes === void 0 ? void 0 : axiosRes.data);
var data = (_b = (_a = axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.response) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : axiosRes === null || axiosRes === void 0 ? void 0 : axiosRes.data;
var code =
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
(data === null || data === void 0 ? void 0 : data.code) ||
(axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.code) ||
((_b = axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.response) === null || _b === void 0 ? void 0 : _b.status) ||
(axiosRes === null || axiosRes === void 0 ? void 0 : axiosRes.status);
var message = (axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.message) || ((_c = axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.response) === null || _c === void 0 ? void 0 : _c.statusText) || (axiosRes === null || axiosRes === void 0 ? void 0 : axiosRes.statusText);
(_f = (_d = (_c = data === null || data === void 0 ? void 0 : data.code) !== null && _c !== void 0 ? _c : axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.code) !== null && _d !== void 0 ? _d : (_e = axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.response) === null || _e === void 0 ? void 0 : _e.status) !== null && _f !== void 0 ? _f : axiosRes === null || axiosRes === void 0 ? void 0 : axiosRes.status;
var message = (axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.message) || ((_g = axiosErr === null || axiosErr === void 0 ? void 0 : axiosErr.response) === null || _g === void 0 ? void 0 : _g.statusText) || (axiosRes === null || axiosRes === void 0 ? void 0 : axiosRes.statusText);
return {

@@ -26,0 +23,0 @@ code: code,

@@ -32,3 +32,4 @@ "use strict";

var cache_1 = require("./cache");
var cache = (0, cache_1.wrapCache)(new Map());
var cachettl_1 = require("./cachettl");
var cache = (0, cache_1.wrapCache)(cachettl_1._ttlcache);
var defaultConfig = {

@@ -35,0 +36,0 @@ cache: cache,

@@ -13,2 +13,2 @@ import type { Canceler, AxiosInstance } from "axios";

];
export declare function useRequest<TRequest extends Request>(fn: TRequest, options?: UseRequestOptions<TRequest>): UseRequestResult<TRequest>;
export declare function useRequest<T extends Request>(fn: T, options?: UseRequestOptions<T>): UseRequestResult<T>;
import type { Canceler, AxiosResponse } from "axios";
import type { Payload, CData, RequestError, Request, RequestDispatcher, RequestCallbackFn } from "./request";
import type { Payload, BodyData, RequestError, Request, RequestDispatcher, RequestCallbackFn } from "./request";
import type { RequestContextConfig } from "./requestContext";

@@ -7,7 +7,7 @@ import type { CacheKey, CacheKeyFn } from "./cache";

data?: Payload<TRequest>;
response?: AxiosResponse<CData<TRequest>>;
error?: RequestError<Payload<TRequest>, CData<TRequest>>;
response?: AxiosResponse<BodyData<TRequest>>;
error?: RequestError<Payload<TRequest>, BodyData<TRequest>>;
isLoading?: boolean;
/** @deprecated Use `response` instead */
other?: AxiosResponse<CData<TRequest>>;
other?: AxiosResponse<BodyData<TRequest>>;
};

@@ -27,3 +27,3 @@ export declare type UseResourceResult<TRequest extends Request> = [

};
export declare function useResource<TRequest extends Request>(fn: TRequest, requestParams?: Parameters<TRequest> | false, options?: UseResourceOptions<TRequest>): UseResourceResult<TRequest>;
export declare function useResource<T extends Request>(fn: T, requestParams?: Parameters<T> | false, options?: UseResourceOptions<T>): UseResourceResult<T>;
export {};
{
"name": "@axios-use/react",
"version": "6.3.0",
"version": "6.4.0-alpha.0",
"description": "A React hook plugin for Axios. Lightweight, cancelable and less change",

@@ -5,0 +5,0 @@ "contributors": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc