fix(core): update

This commit is contained in:
Philipp Kunz 2019-09-29 00:43:37 +02:00
parent 3de7a1a210
commit 5e4afccf9c

View File

@ -13,7 +13,7 @@ export interface IFormField {
const appendFormField = async (formDataArg: plugins.formData, formDataField: IFormField) => { const appendFormField = async (formDataArg: plugins.formData, formDataField: IFormField) => {
if (formDataField.type === 'filePath') { if (formDataField.type === 'filePath') {
let fileData = plugins.fs.readFileSync(plugins.path.join(process.cwd(), formDataField.payload)); const fileData = plugins.fs.readFileSync(plugins.path.join(process.cwd(), formDataField.payload));
formDataArg.append('file', fileData, { formDataArg.append('file', fileData, {
filename: 'upload.pdf', filename: 'upload.pdf',
contentType: 'application/pdf' contentType: 'application/pdf'
@ -30,14 +30,13 @@ export const postFormData = async (
for (const formField of payloadArg) { for (const formField of payloadArg) {
await appendFormField(form, formField); await appendFormField(form, formField);
} }
const requestOptions = Object.assign({}, optionsArg, { const requestOptions = {...optionsArg,
method: 'POST', method: 'POST',
headers: { headers: {
...optionsArg.headers, ...optionsArg.headers,
...form.getHeaders() ...form.getHeaders()
}, },
requestBody: form requestBody: form};
});
// lets fire the actual request for sending the formdata // lets fire the actual request for sending the formdata
const response = await request(urlArg, requestOptions); const response = await request(urlArg, requestOptions);