I'm trying to make something like that.
{
suggestions: [{
"nameClient": "John",
"nameFantasyClient": "smachs"
}, {
"nameClient": "José",
"nameFantasyClient": "apoch"
}]
}
[
{
"nameClient": "John",
"nameFantasyClient": "smachs"
},
{
"nameClient": "José",
"nameFantasyClient": "apoch"
}
]
router.get('/product/sell/name-of-client-search', function (req, res) {
connection.query('SELECT nameClient,nameFantasyClient FROM new_client',
function (err, nameOfClientToSell, fields) {
if (err) {
throw err;
}
res.send(nameOfClientToSell);
}
);
});
You can build the json on the fly.
router.get('/product/sell/name-of-client-search', function (req, res) {
connection.query('SELECT nameClient,nameFantasyClient FROM new_client',
function (err, nameOfClientToSell, fields) {
if (err) {
throw err;
}
res.send({ suggestions: nameOfClientToSell });
}
);
});