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