UNPKG

@push.rocks/smartrequest

Version:

A module for modern HTTP/HTTPS requests with support for form data, file uploads, JSON, binary data, streams, and more.

17 lines (16 loc) 657 B
import * as plugins from './smartrequest.plugins.js'; import * as interfaces from './smartrequest.interfaces.js'; import { request } from './smartrequest.request.js'; export const getStream = async ( urlArg: string, optionsArg: interfaces.ISmartRequestOptions = {} ): Promise<plugins.http.IncomingMessage> => { try { // Call the existing request function with responseStreamArg set to true. const responseStream = await request(urlArg, optionsArg, true); return responseStream; } catch (err) { console.error('An error occurred while getting the stream:', err); throw err; // Rethrow the error to be handled by the caller. } };