angularjs - How to insert data from client to backend using express and mysql? -
i have issue posting data backend, using angularjs on client side problem getting data client can see console.log(post)
printing values angular factory, getting below error. new express , mysql dotn know how fix issue appreciated.
app.js
app.post("/test/create", function(req,res) { var post = { firstname: req.body.firstname, lastname: req.body.lastname, address: req.body.address }; console.log("got data client",post); connection.query('insert worker_table set ?', post, function(error) { if (error) { console.log(error.message); } else { console.log('success'); } connection.end(); }); });
error
got data client { firstname: 'dasd', lastname: 'dad', address: 'dad' } cannot enqueue query after invoking quit. events.js:141 throw er; // unhandled 'error' event ^ error: cannot enqueue quit after invoking quit. @ protocol._validateenqueue (/users/syedhussain/project/node_modules/mysql/lib/protocol/protocol.js:202:16) @ protocol._enqueue (/users/syedhussain/project/node_modules/mysql/lib/protocol/protocol.js:135:13) @ protocol.quit (/users/syedhussain/project/node_modules/mysql/lib/protocol/protocol.js:88:23) @ connection.end (/users/syedhussain/project/node_modules/mysql/lib/connection.js:242:18) @ query._callback (/users/syedhussain/project/app.js:55:20) @ query.sequence.end (/users/syedhussain/project/node_modules/mysql/lib/protocol/sequences/sequence.js:96:24) @ /users/syedhussain/project/node_modules/mysql/lib/protocol/protocol.js:226:14 @ dontcallback0 (node.js:417:9) @ process._tickcallback (node.js:346:13)
Comments
Post a Comment