fix(core): update
This commit is contained in:
parent
d3d0649b73
commit
5e6f2c6fbf
@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartrequest',
|
||||
version: '2.0.8',
|
||||
version: '2.0.9',
|
||||
description: 'dropin replacement for request'
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ export let request = async (
|
||||
responseStreamArg: boolean = false,
|
||||
requestDataFunc: (req: plugins.http.ClientRequest) => void = null
|
||||
): Promise<IExtendedIncomingMessage> => {
|
||||
const done = plugins.smartpromise.defer<any>();
|
||||
const done = plugins.smartpromise.defer<IExtendedIncomingMessage>();
|
||||
|
||||
// merge options
|
||||
const defaultOptions: interfaces.ISmartRequestOptions = {
|
||||
@ -158,7 +158,7 @@ export let request = async (
|
||||
// lets perform the actual request
|
||||
const requestToFire = requestModule.request(optionsArg, async (response) => {
|
||||
if (responseStreamArg) {
|
||||
done.resolve(response);
|
||||
done.resolve(response as IExtendedIncomingMessage);
|
||||
} else {
|
||||
const builtResponse = await buildUtf8Response(response, optionsArg.autoJsonParse);
|
||||
done.resolve(builtResponse);
|
||||
@ -190,6 +190,10 @@ export let request = async (
|
||||
requestToFire.destroy();
|
||||
});
|
||||
|
||||
const result = await done.promise;
|
||||
return result;
|
||||
const response = await done.promise;
|
||||
response.on('error', (err) => {
|
||||
console.log(err);
|
||||
response.destroy();
|
||||
})
|
||||
return response;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user