Our objects are built by the users passing info through a form. We can successfully create and post objects just fine, but we can not delete them.
I've tried many different routes/calls for this but none of them have been successful.
Here is our HTML button to trigger the delete call in Node:
<form id='deleteMe' name='deleteMe' method='delete' action=''deleteMe'>
<input name='_method' value='delete'>
<button type='submit'> delete </button></form>
here is the express route for the deletion itself.
router.post('/deleteMe', function (req, res, next) {
const _id = req.body.id
mongoose.connect(URL, function (err, db) {
assert.equal(null, id)
db.collection('spots').deleteOne({ "_id": objectId(_id) }, function (err, result) {
console.log('op')
assert.equal(null, err);
db.close();
})
});
})
Any help would be so appreciated.