-
Type:
Bug
-
Resolution: Gone away
-
Priority:
Critical - P2
-
None
-
Affects Version/s: None
-
Component/s: None
-
Environment:google cloud platform and bitnami
-
None
-
None
-
None
-
None
-
None
-
None
-
None
mongo save causes error. Insert doesn't. I want to use save
My client javascript:
xmlhttp.open("POST", "http://35.197.106.195");
xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xmlhttp.send(JSON.stringify(myData));
"POST /HTTP/1.1" 502 380
I'm running server app by executing: node app.js . where app.js has the following code:
var port = 3000; app.post("/", (req, res) => var buyer = new Buyer({ email: buyerObj[0].email, . . }).save() .then(item => { console.log("saved to database") res.send("record has been saved"); }) .catch(err => { console.log("err = " + err); res.status(400).send("unable to save to database" + err); }); }); which I changed to var buyers = { email: buyerObj[0].email, . . }; mycollections.insert(buyers); res.send("record saved");
This took care of the 502 error. I also had to add:
?authSource=admin to the connection string to make insert work.
I want to be able to use save() and not insert.