i am trying to add fileUrl property to the order object inside async function but it won't work
i expect the order object to have a fileUrl property after adding it but it won't work
router.get('/my-orders/:id', isAuth, async (req, res) => {
const id = req.params.id;
try {
const orders = await Order.find({ userId: id });
if (orders.length > 0) {
for (const order of orders) {
const getObjectParams = {
Bucket: bucketName,
Key: order.fileName,
}
const command = new GetObjectCommand(getObjectParams);
const url = await getSignedUrl(s3, command, { expiresIn: 3600 });
// adding fileUrl property to order
order.fileUrl = url;
// it logs only order without fileUrl property
console.log(order);
}
res.send('OK');
}
} catch (error) {
console.error(error);
}
})