@vitrical/utils
Advanced tools
Comparing version 1.6.5 to 1.6.6
39
api.js
@@ -7,17 +7,24 @@ "use strict"; | ||
exports.makeMicroserviceRequest = exports.request = exports.removeUndefined = exports.handleApiError = exports.ApiError = void 0; | ||
const axios_1 = __importDefault(require("axios")); | ||
const axios_retry_1 = __importDefault(require("axios-retry")); | ||
(0, axios_retry_1.default)(axios_1.default, { | ||
retries: 3, | ||
retryDelay: (retryCount) => { | ||
console.log(`retry attempt: ${retryCount}`); | ||
return retryCount * 2000; | ||
}, | ||
retryCondition: (error) => { | ||
if (!error.response) { | ||
return false; | ||
} | ||
return error.response.status === 503; | ||
}, | ||
}); | ||
const a = require('axios'); | ||
var Axios = !!a?.request ? a : 'default' in a ? a.default : undefined; | ||
if (Axios) { | ||
(0, axios_retry_1.default)(Axios, { | ||
retries: 3, | ||
retryDelay: (retryCount) => { | ||
console.log(`retry attempt: ${retryCount}`); | ||
return retryCount * 2000; | ||
}, | ||
retryCondition: (error) => { | ||
if (!error.response) { | ||
return false; | ||
} | ||
return error.response.status === 503; | ||
}, | ||
}); | ||
} | ||
else { | ||
console.log('Axios not found'); | ||
console.log(a); | ||
} | ||
function isFetchAvailable() { | ||
@@ -135,3 +142,3 @@ return typeof fetch !== 'undefined'; | ||
const newStack = new Error().stack; | ||
if (isFetchAvailable() && (!isXMLHttpRequestAvailable() || !axios_1.default?.request)) { | ||
if (isFetchAvailable() && (!isXMLHttpRequestAvailable() || !Axios)) { | ||
const bodyData = formData !== undefined | ||
@@ -214,3 +221,3 @@ ? formData | ||
} | ||
const request = axios_1.default.request({ | ||
const request = Axios.request({ | ||
method: lcaseMethod, | ||
@@ -217,0 +224,0 @@ url, |
{ | ||
"name": "@vitrical/utils", | ||
"version": "1.6.5", | ||
"version": "1.6.6", | ||
"description": "Collection of useful functions and typings", | ||
@@ -25,3 +25,3 @@ "main": "index.js", | ||
"@types/jsonwebtoken": "^9.0.5", | ||
"axios": "^1.6.5", | ||
"axios": "^1.7.2", | ||
"axios-retry": "^4.4.0", | ||
@@ -28,0 +28,0 @@ "jsonwebtoken": "^9.0.2", |
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
51507
778
Updatedaxios@^1.7.2