jacksonthompson1 / super-duper-dollop-quebec

https://super-duper-dollop-quebec.onrender.com
GNU General Public License v3.0
1 stars 0 forks source link

ObjectID undefined?? #1

Open jacksonthompson1 opened 7 months ago

jacksonthompson1 commented 7 months ago

trying to fix my /deleteBoard function. I click delete. no delete..

app.post('/deleteBoard', async (req, res) => {
    try {
        const sbId = req.body.id;
        console.log("req.body.id: ", req.body.id);

        await client.connect();

        let result = await client.db("jt-quebec").collection("snowboard").findOneAndDelete({
            "_id": ObjectId(sbId)
        });
        console.log(result);
        res.redirect('/');
    } catch (error) {
        console.error(error);
        res.status(500).send("Internal Server Error");
    } finally {
        await client.close();
    }
});

here's link to the line. https://github.com/jacksonthompson1/super-duper-dollop-quebec/blob/5ac111533743e44c8e9070011e9d07111de740ed/app.js#L102****

jacksonthompson1 commented 7 months ago

maybe im calling it wrong in my index.ejs?

ignore index1.ejs