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

redux-nl

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-nl - npm Package Compare versions

Comparing version 0.1.9 to 0.1.10

2

package.json
{
"name": "redux-nl",
"version": "0.1.9",
"version": "0.1.10",
"description": "A GraphQL inspired rest client side network layer",

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

@@ -121,13 +121,4 @@ /**

},
/**
* Normalises a successful response.
*
* @return {*[]}
*/
normlzDataResponse: response => {
return response.data.data || [];
}
};
export { createRequest };

@@ -28,11 +28,18 @@ /**

const metaInSnakeCase = _omit(_mapKeys(meta, (_, key) => _snakeCase(key)), ["headers"]);
// Extracts parameters from brackets e.g. "/user/orders/{id}" -> id (only supports a single query parameter)
const extractedPathParameter = path
.match(/\{(.+?)\}/g)?.[0]
?.replace(/\{|}/g, "");
// This replaces path parameters with a variable from our 'payload' -> "/user/orders/{id}" -> "/user/orders/35"
const pathWithParams = path.replace(
/\{(.+?)\}/g,
payloadInSnakeCase[extractedPathParameter]
);
// Can optionally include parameters in the path
let pathWithParams = path;
// If there are brackets in the request, we need to replace it with a variable in the payload
if (path.match(/\{(.+?)\}/g) !== null) {
// Extracts parameters from brackets e.g. "/user/orders/{id}" -> id (only supports a single query parameter)
const extractedPathParameter = path
.match(/\{(.+?)\}/g)?.[0]
?.replace(/\{|}/g, "");
// This replaces path parameters with a variable from our 'payload' -> "/user/orders/{id}" -> "/user/orders/35"
pathWithParams = path.replace(
/\{(.+?)\}/g,
payloadInSnakeCase[extractedPathParameter]
);
}
// Build the URL for the request
const url = createRequest.build(pathWithParams, metaInSnakeCase);

@@ -59,3 +66,3 @@

.request(baseUrl, method.toLowerCase(), url, payloadInSnakeCase, meta?.headers)
.then(response => resolve(createRequest.normlzDataResponse(response)))
.then(response => resolve(response))
.catch(error => reject(error));

@@ -62,0 +69,0 @@ });

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