app.post('/uapp', async (req, res) => { try { await client.connect(); const db = client.db('hospital'); const collection = db.collection('patients'); const { pname, page, psex, pplace, pdepartment, pdoctor, pbloodgroup, pphone, pdate, pemail } = req.body; const myobj = { pname, page, psex, pplace, pdepartment, pdoctor, pbloodgroup, pphone, pdate, pemail }; await collection.insertOne(myobj); console.log("1 document inserted"); res.redirect('/uapp'); // Redirect after successful insertion } catch (err) { console.error("Error:", err); } finally { await client.close(); } });