ladjs / superagent

Ajax for Node.js and browsers (JS HTTP client). Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
https://ladjs.github.io/superagent/
MIT License
16.58k stars 1.33k forks source link

Attaching multiple files to a request fails. #1605

Open Harpreet-rapido opened 3 years ago

Harpreet-rapido commented 3 years ago

const result = await superagent .post('url') .attach('driving_license', fs.createReadStream(filePath)) .field('dl_number', 'dlInfo.dlNo') .field('dob', 'dlInfo.dob') .field('apikey', 'apikey') .attach('photo', fs.createReadStream(filePath));

Using attach multiple times does not allow the file to get attached.

This on the other hand works- await superagent .post('url') .field('rc_number', rcInfo.rcNumber) .field('apikey', 'apiKey') .attach('rcbook', fs.createReadStream(filePath));