packages/target-tools/src/fetchWithTelemetry.js
/**
 * Invokes the REST service using the supplied settings and parameters.
 * @param {String} host The server host.
 * @param {String} path The base URL to invoke.
 * @param {Object.<String, Object>} queryParams A map of query parameters and their values.
 * @param {Object} requestOpts Various request options:  body, headers, timeout, agent
 * @returns {Promise} A {@link https://www.promisejs.org/|Promise} object.
 */
Invokes the REST service using the supplied settings and parameters.
@param {String} host The server host.
@param {String} path The base URL to invoke.
@param {Object.} queryParams A map of query parameters and their values.
Invokes the REST service using the supplied settings and parameters . @param { String } host The server host . @param { String } path The base URL to invoke . @param { Object . } queryParams A map of query parameters and their values .
function handleRequest(host, path, queryParams, requestOpts, requestImpl) {
  const { body, protocol, timeout = 10000 } = requestOpts;
  const options = createRequestOptions(host, path, queryParams, requestOpts);
  return new Promise((resolve, reject) => {
    const callback = (err, response) => {
      if (err) {
        reject(err);
        return;
      }
      resolve(response);
    };
    executeRequest(
      options,
      body,
      timeout,
      callback,
      determineRequestImpl(protocol, requestImpl)
    );
  });
}
function handleRequest ( host , path , queryParams , requestOpts , requestImpl ) { const { body , protocol , timeout = 10000 } = requestOpts ; const options = createRequestOptions ( host , path , queryParams , requestOpts ) ; return new Promise ( ( resolve , reject ) => { const callback = ( err , response ) => { if ( err ) { reject ( err ) ; return ; } resolve ( response ) ; } ; executeRequest ( options , body , timeout , callback , determineRequestImpl ( protocol , requestImpl ) ) ; } ) ; }
Invokes the REST service using the supplied settings and parameters.
Invokes the REST service using the supplied settings and parameters .