react-hooks-library
Advanced tools
Comparing version 0.0.34 to 0.0.35
@@ -21,5 +21,9 @@ import { AxiosRequestConfig, AxiosResponse } from 'axios'; | ||
cancel: () => void; | ||
refetch: (variable?: object | undefined) => Promise<void | [boolean, AxiosResponse<P>]>; | ||
refetch: (variable?: object | undefined) => Promise<void | { | ||
isSuccess: boolean; | ||
response: AxiosResponse<P>; | ||
data: P; | ||
}>; | ||
startPolling: (interval: number, variable?: object | undefined) => void; | ||
stopPolling: () => void; | ||
}; |
@@ -60,3 +60,3 @@ import * as tslib_1 from "tslib"; | ||
return tslib_1.__awaiter(_this, void 0, void 0, function () { | ||
var query, queryResult, isSuccess, queryResponse, error_1; | ||
var query, queryResult, isSuccess, queryResponse, queryData, error_1; | ||
return tslib_1.__generator(this, function (_a) { | ||
@@ -75,7 +75,7 @@ switch (_a.label) { | ||
if (queryResult) { | ||
isSuccess = queryResult[0], queryResponse = queryResult[1]; | ||
isSuccess = queryResult.isSuccess, queryResponse = queryResult.response, queryData = queryResult.data; | ||
if (isSuccess) { | ||
setData(queryResponse.data); | ||
setData(queryData); | ||
typeof props.onSuccess === 'function' && | ||
props.onSuccess(queryResponse.data, queryResponse); | ||
props.onSuccess(queryData, queryResponse); | ||
} | ||
@@ -82,0 +82,0 @@ else { |
import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios'; | ||
export declare type IHandleReponse<T> = (response: AxiosResponse<T>) => [boolean, AxiosResponse<T>]; | ||
export declare type IHandleReponse<T> = (response: AxiosResponse<T>) => { | ||
isSuccess: boolean; | ||
response: AxiosResponse<T>; | ||
data: T; | ||
}; | ||
export declare type IHandleError = (error: AxiosError) => void; | ||
@@ -9,3 +13,7 @@ export declare const defaultsConfig: AxiosRequestConfig; | ||
}) => void; | ||
export declare const request: <T>(config: AxiosRequestConfig) => Promise<void | [boolean, AxiosResponse<T>]>; | ||
export declare const request: <T>(config: AxiosRequestConfig) => Promise<void | { | ||
isSuccess: boolean; | ||
response: AxiosResponse<T>; | ||
data: T; | ||
}>; | ||
export { axios }; |
var _this = this; | ||
import * as tslib_1 from "tslib"; | ||
import axios from 'axios'; | ||
var handleResponse = function (response) { return [true, response]; }; | ||
var handleResponse = function (response) { return ({ | ||
isSuccess: true, | ||
response: response, | ||
data: response.data, | ||
}); }; | ||
var handleError = function () { }; | ||
@@ -6,0 +10,0 @@ export var defaultsConfig = { |
{ | ||
"name": "react-hooks-library", | ||
"version": "0.0.34", | ||
"version": "0.0.35", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20048
509