The problem is that when I start the server I get the error listed below. I'm pretty new to JavaScript, is this due to a difference in JavaScript or Nodejs versions? I also tried changing the var update to have [] instead of {}, but which gets the server to start, but then it won't update/delete data from our MongoDB. If it helps, the "Recipes" in Recipes.findOneAndUpdate is a Mongoose schema.
Here is the function from the server.js:
app.post("/updaterecipe", function(req, res) {
var id = req.body.recipeID;
console.log("Updating recipe " + id);
var recipeName = req.body.recipeName;
var categoryID = req.body.categoryID;
var recipeInstructions = req.body.recipeInstructions;
var ingredientIDs = req.body.ingredientIDs;
var options = {new: false};
var update = {recipeName, categoryID, recipeInstructions, ingredientIDs};
console.log(update);
Recipes.findOneAndUpdate({recipeID: id}, update, options, function(err) {
if (err)
{
console.log("Unable to update");
console.log(err);
}
});
res.send(update);
});
And the error:
var update = {recipeName, categoryID, recipeInstructions, ingredientIDs};
^
SyntaxError: Unexpected token , at exports.runInThisContext (vm.js:73:16) at Module._compile (module.js:443:25) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10) at startup (node.j