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

react-hooks-library

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hooks-library - npm Package Compare versions

Comparing version 0.1.2 to 0.1.4

13

demo/request.ts

@@ -1,11 +0,10 @@

import { axiosRequest, axios } from '../src/request'
import { axiosRequest } from '../src/request'
// tslint:disable-next-line: export-name
export const request = axiosRequest<[]>({
handleResponse: res => {
return res.data
export const request = axiosRequest({
handleResponse: response => {
return response.data
},
catchErrors: err => {
throw err
catchErrors: error => {
throw error
},
})
import axios, { AxiosRequestConfig, AxiosResponse, AxiosError } from 'axios';
export interface IAaxiosHandles<Response> {
handleResponse?<Data>(res: AxiosResponse<Response>, ...rest: any[]): Data | Response;
export declare type IHandleResponse<P, Data = P> = (res: AxiosResponse<Data>, ...rest: any[]) => Data;
export interface IAaxiosHandles<ResponseData> {
handleResponse: IHandleResponse<ResponseData>;
catchErrors?(err: AxiosError): void;
}
export declare function axiosRequest<IResponse>(handles: IAaxiosHandles<IResponse>): {
request: (method: string) => (userConfig: AxiosRequestConfig, ...rest: any[]) => (config: AxiosRequestConfig) => Promise<void | {} | IResponse>;
get: (userConfig: AxiosRequestConfig, ...rest: any[]) => (config: AxiosRequestConfig) => Promise<void | {} | IResponse>;
post: (userConfig: AxiosRequestConfig, ...rest: any[]) => (config: AxiosRequestConfig) => Promise<void | {} | IResponse>;
put: (userConfig: AxiosRequestConfig, ...rest: any[]) => (config: AxiosRequestConfig) => Promise<void | {} | IResponse>;
patch: (userConfig: AxiosRequestConfig, ...rest: any[]) => (config: AxiosRequestConfig) => Promise<void | {} | IResponse>;
delete: (userConfig: AxiosRequestConfig, ...rest: any[]) => (config: AxiosRequestConfig) => Promise<void | {} | IResponse>;
export declare function axiosRequest<ResponseData>(handles: IAaxiosHandles<ResponseData>): {
request: (method: string) => <Data>(userConfig: AxiosRequestConfig, ...rest: any[]) => (config: AxiosRequestConfig) => Promise<void | Data>;
get: <Data>(userConfig: AxiosRequestConfig, ...rest: any[]) => (config: AxiosRequestConfig) => Promise<void | Data>;
post: <Data>(userConfig: AxiosRequestConfig, ...rest: any[]) => (config: AxiosRequestConfig) => Promise<void | Data>;
put: <Data>(userConfig: AxiosRequestConfig, ...rest: any[]) => (config: AxiosRequestConfig) => Promise<void | Data>;
patch: <Data>(userConfig: AxiosRequestConfig, ...rest: any[]) => (config: AxiosRequestConfig) => Promise<void | Data>;
delete: <Data>(userConfig: AxiosRequestConfig, ...rest: any[]) => (config: AxiosRequestConfig) => Promise<void | Data>;
};
export { axios };

@@ -10,3 +10,5 @@ import * as tslib_1 from "tslib";

return handles.handleResponse
? handles.handleResponse.apply(undefined, [response].concat(rest))
? handles.handleResponse.apply(undefined, [
response
].concat(rest))
: response.data;

@@ -28,3 +30,5 @@ }

.request(tslib_1.__assign({}, userConfig, config, { method: method }))
.then(function (response) { return handleResponse.apply(undefined, [response].concat(rest)); })
.then(function (response) {
return handleResponse.apply(undefined, [response].concat(rest));
})
.catch(catchErrors)];

@@ -31,0 +35,0 @@ });

{
"name": "react-hooks-library",
"version": "0.1.2",
"version": "0.1.4",
"license": "MIT",

@@ -5,0 +5,0 @@ "scripts": {

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