How to set Array Response in Axios,Express?

Viewed 24

please help me , How to set column and data in res.send

app.post('/customer', (req, res) => {
    db.query(
        'SELECT a.CustomerName, a.Phone, a.Email, b.ProjectId, GROUP_CONCAT( p.ProjectCode ) AS Project, GROUP_CONCAT( t.TypeCusDes ) AS TypeCus FROM a LEFT JOIN b ON b.CrmCustomerId = a.CrmCustomerId LEFT JOIN t ON t.TypeCusId = b.TypeCusId LEFT JOIN pON p.ProjectId = b.ProjectId WHERE a.CustomerName LIKE ? GROUP BY a.CustomerId',
        [req.body.CustomerName],
        (err, result) => {
            if (err) {
                console.log(err);
            } else {
                res.send([
                    {
                        //SET
                        CustomerName: result.CustomerName,
                        Phone: result.Phone,
                        Email: result.Email,
                        ProjectId: result.ProjectId,
                        Project: result.Project,
                        TypeCus: result.TypeCus,
                    },
                ]);
            }
        },
    );
});

hope you guys can help

0 Answers
Related