Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app.post("/commanda", function (req, res) {
- var idCuenta = req.body.idCuenta;
- var idEmpleado = req.body.idEmpleado;
- var fechaRegistro = req.body.fechaRegistro;
- var cuenta_mesero = "C:" + idCuenta + ":E:" + idEmpleado;
- var objects = req.body.objects;
- var element = {};
- //for (var key in objects) {
- asyncloop(Object.keys(objects).length, function (loop) {
- if (objects.hasOwnProperty(Object.keys(objects)[loop.iteration()])) {
- var qProducto = "SELECT descripcionProducto FROM PRODUCTO WHERE idProducto = ? ;";
- var descProducto = '';
- console.log("cantidad in commanda2 : " + objects[Object.keys(objects)[loop.iteration()]].cantidad);
- try {
- pool.query(qProducto, objects[Object.keys(objects)[loop.iteration()]].idProducto, function (error, results, fields) {
- if (error) {
- console.error(error);
- console.error("Failed with query: " + qProducto);
- res.status(500).end();
- loop.break();
- throw error;
- } else {
- console.log("cantidad in commanda4 : " + objects[Object.keys(objects)[loop.iteration()]].cantidad);
- descProducto = JSON.stringify(results[0].descripcionProducto);
- element = {
- idProducto: objects[Object.keys(objects)[loop.iteration()]].idProducto,
- cantidad: objects[Object.keys(objects)[loop.iteration()]].cantidad,
- descProducto: descProducto,
- cuenta_mesero: cuenta_mesero,
- fechaRegistro: fechaRegistro
- };
- imprimirOrden(element);
- loop.next();
- }
- });
- } catch (error) {
- callback(error);
- }
- }
- }, function () {
- //This is your final callback
- //ALL OBJECTS HANDLED PROPERLY. Maybe put your res.end here instead?
- printer.printVerticalTab();
- res.status(200).end();
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement