update the way requests are ended

This commit is contained in:
Philipp Kunz 2018-07-19 23:22:11 +02:00
parent 0c03763281
commit 31b326cf51

View File

@ -96,9 +96,12 @@ export let request = async (
) { ) {
optionsArg.requestBody = JSON.stringify(optionsArg.requestBody); optionsArg.requestBody = JSON.stringify(optionsArg.requestBody);
request.write(optionsArg.requestBody); request.write(optionsArg.requestBody);
request.end();
} else if (optionsArg.requestBody instanceof plugins.formData) { } else if (optionsArg.requestBody instanceof plugins.formData) {
optionsArg.requestBody.pipe(request); optionsArg.requestBody.pipe(request);
} }
} else {
request.end();
} }
// lets handle an error // lets handle an error
@ -116,8 +119,6 @@ export let request = async (
} }
}); });
request.end();
const result = await done.promise; const result = await done.promise;
return result; return result;
}; };