@vitrical/utils
Advanced tools
Comparing version 1.2.8 to 1.3.0
17
api.js
@@ -31,4 +31,15 @@ "use strict"; | ||
} | ||
const message = res.body?.msg | ||
? `Request failed with status code ${res.status} ( ${res.body.msg} )` | ||
const requestMsg = typeof res.body?.msg === 'string' | ||
? res.body.msg | ||
: typeof res.body?.error === 'string' | ||
? res.body.error | ||
: typeof res.body?.message === 'string' | ||
? res.body.message | ||
: typeof res.body === 'string' | ||
? res.body | ||
: typeof res.body?.text === 'string' | ||
? res.body.text | ||
: undefined; | ||
const message = requestMsg | ||
? `Request failed with status code ${res.status} ( ${requestMsg} )` | ||
: `Request failed with status code ${res.status}`; | ||
@@ -41,3 +52,3 @@ const apiError = new ApiError(message); | ||
apiError.url = url; | ||
apiError.msg = res.body?.msg || ''; | ||
apiError.msg = requestMsg ?? message; | ||
return apiError; | ||
@@ -44,0 +55,0 @@ } |
{ | ||
"name": "@vitrical/utils", | ||
"version": "1.2.8", | ||
"version": "1.3.0", | ||
"description": "Collection of useful functions and typings", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
48637
832