Is there a way to pass data from Vue to an express server? For example, in the scenario below, I am looking to send the data logged in my Vue function to the "id" variable on the server side.
expressApp.post('/delete' , function (request, response) {
const id = request.body.id;
console.log(id)
MongoClient.connect(url, function (err, db) {
if (err) throw err;
let dbo = db.db(dbName);
dbo.collection("Members").deleteOne({"_id": objectId(id)}, function (err, res) {
if (err) throw err;
db.close();
});
});
response.redirect('/agileApp');
});
t: function (index) {
fetch(membersUrl).then(function(response) {
return response.json();
}).then(function (data) {
const formData = new FormData();
formData.append("id", data[index]._id);
for (var pair of formData.entries()) {
console.log(pair[0]+ ', ' + pair[1]);
}
fetch(deleteUrl, {
method: 'POST',
body: formData
})
})
}