Socket
Socket
Sign inDemoInstall

@vitrical/utils

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vitrical/utils - npm Package Compare versions

Comparing version 1.3.3 to 1.3.4

38

api.js

@@ -8,3 +8,2 @@ "use strict";

const axios_1 = __importDefault(require("axios"));
const axios_fetch_adapter_1 = __importDefault(require("@vespaiach/axios-fetch-adapter"));
function isFetchAvailable() {

@@ -79,4 +78,39 @@ return typeof fetch !== 'undefined';

const newStack = new Error().stack;
if (isFetchAvailable()) {
const request = fetch(url, {
method,
body: body && typeof body === 'string' ? body : JSON.stringify(body),
headers: {
...headers,
...(body && typeof body === 'string'
? { 'Content-Type': 'text/plain' }
: { 'Content-Type': 'application/json' }),
},
});
request
.then(async (res) => {
const body = await res.json();
if (res.status >= 400) {
const apiError = new ApiError(`Request failed with status code ${res.status} ( ${body?.msg ?? body?.error ?? body?.message ?? ''} )`);
apiError.body = body;
apiError.headers = res.headers;
apiError.status = res.status;
apiError.stack = newStack;
apiError.url = url;
apiError.msg = body?.msg ?? body?.error ?? body?.message ?? '';
reject(apiError);
return;
}
resolve({
status: res.status,
body,
headers: res.headers,
});
})
.catch((err) => {
reject(err);
});
return;
}
const request = axios_1.default.request({
adapter: isFetchAvailable() ? axios_fetch_adapter_1.default : undefined,
method,

@@ -83,0 +117,0 @@ url,

3

package.json
{
"name": "@vitrical/utils",
"version": "1.3.3",
"version": "1.3.4",
"description": "Collection of useful functions and typings",

@@ -26,3 +26,2 @@ "main": "index.js",

"@types/superagent": "^4.1.16",
"@vespaiach/axios-fetch-adapter": "^0.3.1",
"axios": "^1.4.0",

@@ -29,0 +28,0 @@ "jsonwebtoken": "^9.0.0",

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