UNPKG

1.1 kBJavaScriptView Raw
1"use strict";
2// Copyright IBM Corp. 2018. All Rights Reserved.
3// Node module: @loopback/testlab
4// This file is licensed under the MIT License.
5// License text available at https://opensource.org/licenses/MIT
6Object.defineProperty(exports, "__esModule", { value: true });
7const http = require("http");
8const https = require("https");
9const url = require("url");
10/**
11 * Async wrapper for making HTTP GET requests
12 * @param urlString
13 */
14function httpGetAsync(urlString) {
15 return new Promise((resolve, reject) => {
16 http.get(urlString, resolve).on('error', reject);
17 });
18}
19exports.httpGetAsync = httpGetAsync;
20/**
21 * Async wrapper for making HTTPS GET requests
22 * @param urlString
23 */
24function httpsGetAsync(urlString) {
25 const agent = new https.Agent({
26 rejectUnauthorized: false,
27 });
28 const urlOptions = url.parse(urlString);
29 const options = Object.assign({ agent }, urlOptions);
30 return new Promise((resolve, reject) => {
31 https.get(options, resolve).on('error', reject);
32 });
33}
34exports.httpsGetAsync = httpsGetAsync;
35//# sourceMappingURL=request.js.map
\No newline at end of file