0

This is in my routes/product.js file in my node.js/express project which is using express-myconnection. How do I return multiple data sets for the view to use? I have the data object and the dropdown object being populated by the same query. I want to keep the data object like it is, but populate the dropdown object with a different query.

exports.edit = function(req, res) {
    var id = req.params.id;
    req.getConnection(function (err, connection) {
        connection.query('SELECT * FROM products WHERE product_id = ?', [id], function (err, rows) {
            if (err)
                console.log("Error Selecting : %s ", err);
            res.render('products\\edit', {
                page_title: "Product : Edit",
                save_button_title: "Update",
                data: rows,
                dropdown:rows});
        });
    });
}

1 Answer 1

1

You can either nest another database call inside your first "success" area or you can try something like this: Node.js - wait for multiple async calls

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.