Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
3417f09cdb | |||
20dc3c9230 | |||
6f865a356f | |||
71a6ffef96 | |||
189916e62b | |||
33e36b5d44 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartrequest",
|
||||
"version": "1.1.6",
|
||||
"version": "1.1.9",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartrequest",
|
||||
"version": "1.1.6",
|
||||
"version": "1.1.9",
|
||||
"private": false,
|
||||
"description": "dropin replacement for request",
|
||||
"main": "dist/index.js",
|
||||
|
@ -35,11 +35,13 @@ const appendFormField = async (
|
||||
formDataField: IFormField
|
||||
) => {
|
||||
if (formDataField.type === "filePath") {
|
||||
formDataArg.append("type", "image");
|
||||
let fileData = plugins.fs.createReadStream(
|
||||
let fileData = plugins.fs.readFileSync(
|
||||
plugins.path.join(process.cwd(), formDataField.payload)
|
||||
);
|
||||
formDataArg.append("media", fileData, "upload.pdf");
|
||||
formDataArg.append("file", fileData, {
|
||||
filename: 'upload.pdf',
|
||||
contentType: 'application/pdf'
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@ -55,8 +57,15 @@ export const postFormData = async (
|
||||
const pipeLog: any = async (...args) => {
|
||||
console.log(args);
|
||||
};
|
||||
const requestOptions = Object.assign({}, optionsArg, { requestBody: form });
|
||||
const requestOptions = Object.assign({}, optionsArg, {
|
||||
headers: {
|
||||
...(optionsArg.headers),
|
||||
...getFormDataHeaders(form)
|
||||
},
|
||||
requestBody: form
|
||||
});
|
||||
|
||||
// lets fire the actual request for sending the formdata
|
||||
request(urlArg, requestOptions);
|
||||
const response = await request(urlArg, requestOptions);
|
||||
return response;
|
||||
};
|
||||
|
Reference in New Issue
Block a user