Hi I am trying to pass the below data in stream form as the normal response is taking too long because of conversion of images into base64data
Looking at various similar issues I tried changing the response to pipe() but still facing issues
Please see below code for reference
Hence can you please tell me how to pass the response in stream form and check it in postman
router.js
router.get("/users/data/expand/:nid", async (req, res) => {
var idselected = req.params.nid;
var dir = "images";
try {
const checkData = await user.findOne({ user_id: idselected });
let receivedFile = await Promise.all(
checkData.attachments.flatMap(async element => {
let files = await readDirectory(dir);
return await Promise.all(
files.map(filename => {
filename = element;
return readFile(filename)
})
);
})
);
const returnUser = new User({
user_id: checkData.user_id,
attachments: receivedFile
});
let savedUser = await returnUser.save();
res.status(201).pipe(savedUser);
} catch (e) {
res.status(500).send(e);
}
});