myfetchapi
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -39,3 +39,8 @@ "use strict"; | ||
return { success: true, res }; | ||
return { success: false, msg: new Error(res.statusText) }; | ||
return { | ||
success: false, | ||
msg: new Error( | ||
`statusCode: ${res.status}, response: "${await getText(res)}"` | ||
) | ||
}; | ||
} catch (err) { | ||
@@ -45,4 +50,11 @@ return { success: false, msg: err }; | ||
} | ||
async function getText(res) { | ||
try { | ||
return (await res.text()).substring(0, 250); | ||
} catch (_) { | ||
return ""; | ||
} | ||
} | ||
async function myFetch(input, init = {}, options) { | ||
const maxRetry = options?.maxRetry === void 0 ? 3 : options.maxRetry === null ? 0 : options.maxRetry; | ||
const maxRetry = options?.maxRetry === void 0 ? 3 : options.maxRetry === null ? 0 : options.maxRetry < 0 ? 0 : options.maxRetry; | ||
return new Promise((resolve, reject) => { | ||
@@ -49,0 +61,0 @@ const executeRequest = async (retryCount) => { |
{ | ||
"name": "myfetchapi", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "mFetch is a JavaScript library that provides a utility function for making HTTP requests with queuing and retry functionality.", | ||
@@ -5,0 +5,0 @@ "type": "commonjs", |
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
20142
286