@varlet/axle 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/use.d.ts +2 -2
- package/es/use.js +2 -2
- package/package.json +1 -1
package/es/use.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export interface CreateUseAxleOptions {
|
|
|
8
8
|
config?: AxleRequestConfig;
|
|
9
9
|
immediate?: boolean;
|
|
10
10
|
dataTransformer?(data: any, prevData: any): any;
|
|
11
|
-
errorTransformer?(errorResponse: Error): Error;
|
|
11
|
+
errorTransformer?(errorResponse: Error, prevError: Error | undefined): Error;
|
|
12
12
|
}
|
|
13
13
|
export interface RunOptions<P> {
|
|
14
14
|
url?: string;
|
|
@@ -24,7 +24,7 @@ export interface UseAxleOptions<D, P, R> {
|
|
|
24
24
|
config?: AxleRequestConfig;
|
|
25
25
|
immediate?: boolean;
|
|
26
26
|
dataTransformer?(response: R, prevData: D): D;
|
|
27
|
-
errorTransformer?(errorResponse: Error): Error;
|
|
27
|
+
errorTransformer?(errorResponse: Error, prevError: Error | undefined): Error;
|
|
28
28
|
}
|
|
29
29
|
export declare function createUseAxle(options?: CreateUseAxleOptions): <D = any, P = any, R = any>(options?: UseAxleOptions<D, P, R>) => [data: Ref<UnwrapRef<D>>, run: Run<D, P>, loading: Ref<UnwrapRef<boolean>>, extra: {
|
|
30
30
|
error: Ref<UnwrapRef<Error | undefined>>;
|
package/es/use.js
CHANGED
|
@@ -6,7 +6,7 @@ export function createUseAxle(options = {}) {
|
|
|
6
6
|
const defaultInitialData = options.data;
|
|
7
7
|
const defaultInitialParams = options.params;
|
|
8
8
|
const defaultInitialConfig = options.config;
|
|
9
|
-
const defaultImmediate = (_a = options.immediate) !== null && _a !== void 0 ? _a :
|
|
9
|
+
const defaultImmediate = (_a = options.immediate) !== null && _a !== void 0 ? _a : false;
|
|
10
10
|
const defaultDataTransformer = (_b = options.dataTransformer) !== null && _b !== void 0 ? _b : ((v) => v);
|
|
11
11
|
const defaultErrorTransformer = (_c = options.errorTransformer) !== null && _c !== void 0 ? _c : ((v) => v);
|
|
12
12
|
const useAxle = (options = {}) => {
|
|
@@ -34,7 +34,7 @@ export function createUseAxle(options = {}) {
|
|
|
34
34
|
})
|
|
35
35
|
.catch((responseError) => {
|
|
36
36
|
data.value = initialData;
|
|
37
|
-
error.value = errorTransformer(responseError);
|
|
37
|
+
error.value = errorTransformer(responseError, error.value);
|
|
38
38
|
loading.value = false;
|
|
39
39
|
throw responseError;
|
|
40
40
|
});
|