I'm facing a huge problem here, and I don't know how to solve it:
I have a simple route (which works) in nodejs made with express:
public static create(router: Router, basePath: string) {
console.log("[SearchRoute::create] Creating routes for /search.");
// call the function for retrieving the address book results
router.get(basePath + "/search/:searchString",
function (req, res, next) {
console.log(searchUser(req.params.searchString));
});
}
And i have the searchUser function with a simple query:
function searchUser(searchString) {
console.log("searchUser Function executed.");
return myMYSQL.connection.query('SELECT XXX FROM XXX WHERE ?',[searchString],
function (error, results) {
if (error) throw error;
return (results);
});
The problem that I'm facing is:
In searchUser, the result of the query it's giving me 2 objects.
But in the route (the first function), it's only printing me one result in the values index of the result.
I think the error it's in the return of the searchUser function, I'm somehow returning it wrong and missing something.
Thank you so much to all for your help!
via DaRo
No comments:
Post a Comment