node js post multipart 2fform data

Solutions on MaxInterview for node js post multipart 2fform data by the best coders in the world

showing results for - "node js post multipart 2fform data"
Ailsa
01 Apr 2020
1var jsonUpload = {  };
2var formData = {
3    'file': fs.createReadStream(fileName),
4    'jsonUpload': JSON.stringify(jsonUpload)
5};
6var uploadOptions = {
7    "url": "https://upload/url",
8    "method": "POST",
9    "headers": {
10        "Authorization": "Bearer " + accessToken
11    },
12    "formData": formData
13}
14var req = request(uploadOptions, function(err, resp, body) {
15    if (err) {
16        console.log('Error ', err);
17    } else {
18        console.log('upload successful', body)
19    }
20});
21