New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

rest-api-kit

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rest-api-kit - npm Package Compare versions

Comparing version 0.0.17 to 0.0.18

4

dist/index.d.ts

@@ -26,3 +26,3 @@ type MethodType = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";

endpointName: string;
successCondition: (data: unknown) => boolean;
successCondition: (data: any) => boolean;
transformResponse: (data: unknown) => unknown;

@@ -55,3 +55,3 @@ }

declare function useRest(url: string, params?: Partial<IOptions>, options?: Partial<RestOptionsType>): QueryHookReturnType;
declare function useRest(url: string, paramsFromBase?: Partial<IOptions>, options?: Partial<RestOptionsType>): QueryHookReturnType;

@@ -58,0 +58,0 @@ declare const createRestBase: (restBaseOptions?: Partial<RestOptionsType>) => RestBaseReturnType;

@@ -190,3 +190,3 @@ "use strict";

};
function useRest(url, params = {}, options = {}) {
function useRest(url, paramsFromBase = {}, options = {}) {
const [state, dispatch] = (0, import_react2.useReducer)(reducer2, initState2);

@@ -196,9 +196,9 @@ const { save: saveToStore, get: getFromStore, clear: clearFromStore } = useStore();

try {
const allParams = { ...defaultOptions, params };
const params = { ...defaultOptions, ...paramsFromBase };
url = getBaseUrl(url, options?.baseUrl);
let storeIdentifier = `${options.baseUrl || ""}&${params.endpointName}`;
if (Object(params).hasOwnProperty("preferCachevalue")) {
if (params.preferCachevalue) {
let cachedResult = getFromStore(storeIdentifier);
if (cachedResult) {
applyChecks(allParams, dispatch, cachedResult);
applyChecks(params, dispatch, cachedResult);
return;

@@ -211,7 +211,7 @@ }

const response = await makeRequest(concatenateParamsWithUrl(url, body));
dispatch({ type: "data/success", payload: applyChecks(allParams, dispatch, response) });
dispatch({ type: "data/success", payload: applyChecks(params, dispatch, response) });
if (params?.saveToCache) {
saveToStore(storeIdentifier, response, { ...defaultOptions, ...params });
}
if (Object(params).hasOwnProperty("updates")) {
if (params.updates.length > 0) {
clearMultipleIds(params.updates, options.baseUrl || "", (id) => clearFromStore(id));

@@ -218,0 +218,0 @@ }

{
"name": "rest-api-kit",
"version": "0.0.17",
"version": "0.0.18",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "module": "dist/index.mjs",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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