@altangent/lib-http
Advanced tools
Comparing version 0.12.8 to 0.12.9
@@ -7,2 +7,3 @@ export declare type requestOptions = { | ||
rejectUnauthorized?: boolean; | ||
returnRaw?: boolean; | ||
}; | ||
@@ -13,2 +14,2 @@ /** | ||
*/ | ||
export declare function request({ url, method, headers, json, rejectUnauthorized, }: requestOptions): Promise<any>; | ||
export declare function request({ url, method, headers, json, rejectUnauthorized, returnRaw, }: requestOptions): Promise<any>; |
@@ -15,3 +15,3 @@ "use strict"; | ||
*/ | ||
function request({ url, method = "GET", headers = {}, json, rejectUnauthorized, }) { | ||
function request({ url, method = "GET", headers = {}, json, rejectUnauthorized, returnRaw = false, }) { | ||
return new Promise((resolve, reject) => { | ||
@@ -34,3 +34,3 @@ const { protocol, hostname, port, path } = urlutil.parse(url); | ||
const statusCode = res.statusCode; | ||
const body = safeParse(rawBody); | ||
const body = returnRaw ? rawBody : safeParse(rawBody); | ||
if (statusCode === 200) { | ||
@@ -37,0 +37,0 @@ resolve(body); |
@@ -16,2 +16,3 @@ /* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
rejectUnauthorized?: boolean; | ||
returnRaw?: boolean; | ||
}; | ||
@@ -29,2 +30,3 @@ | ||
rejectUnauthorized, | ||
returnRaw = false, | ||
}: requestOptions): Promise<any> { | ||
@@ -52,3 +54,3 @@ return new Promise((resolve, reject) => { | ||
const statusCode = res.statusCode; | ||
const body = safeParse(rawBody); | ||
const body = returnRaw ? rawBody : safeParse(rawBody); | ||
if (statusCode === 200) { | ||
@@ -55,0 +57,0 @@ resolve(body); |
{ | ||
"name": "@altangent/lib-http", | ||
"version": "0.12.8", | ||
"version": "0.12.9", | ||
"description": "Basic HTTP/S client utilities", | ||
@@ -26,3 +26,3 @@ "author": "Brian Mancini <bmancini@gmail.com>", | ||
"homepage": "https://github.com/altangent/libs/tree/main/packages/http", | ||
"gitHead": "9148b93bd49ecf5d7e20e9cee500987353b9e7d7", | ||
"gitHead": "4c7a6ea0f0d39032d0aee188d2c403a0f92ceaaf", | ||
"publishConfig": { | ||
@@ -29,0 +29,0 @@ "access": "public" |
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
11935
203