I'm trying to execute a callback function in nodejs, using expressjs and angular 2 (i don't know if the angular2 part it's relevant).

What I do is:
I have a formular in angular2, with that I send a get request to my API route, then I send the text field in the formular to the URL via get, then I do an MYSQL query to look into a phonebook database, and I'm expecting to get a complete user with his details, from the phonebook.

Formular:

```
<div class="container">
<div class="col-md-4">
<h1>Addressbook</h1>
<form [formGroup]="searchForm" (ngSubmit)="doSearch($event)">
<input formControlName="searchString" type="text" placeholder="Name">
<button type="submit">Search</button>
</form>
</div>
</div>

```

First function, doSearch:

```
doSearch(event) {
    let formData = this.searchForm.value;
    var searchString = this.searchForm.value.searchString;

    this.http.get('/phonebook/search/'+searchString, function(req, res){}).subscribe(
    function(response) {
    console.log("Success Response");
    },
    function(error) { console.log("Error happened" + error)},
    function() { console.log("the subscription is completed")}
    );
}

```

This calls to the route sending a parameter, so not so hard.

Now the create router gets into the game:

```
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", (req: Request, res: Response, next: NextFunction) => {
    console.log("##  [SearchRoute] Called GET /search.");
    var object = searchUser(req);
    console.log(object);
        });
}

```

And finally, the function searchUser gets called:

```
function searchUser(req: Request) {

    console.log("searchUser Function executed.");

    var searchString = req.params.searchString;

    var query = p_query('SELECT XXXX')
    .then(function (results) {
    console.log("query executed and all okay");
    return (results);
    })
    .catch(function (error) {
    console.error("Wooopsi", error);
    });

    console.log("query result: "+query);
}

```

Additionally, I post here the new query function that I build to be able to handle promises (which I don't know if it was the best choice):

```
function p_query(q) {
    return new Promise(function (resolve, reject) {
    // The Promise constructor should catch any errors thrown on
    // this tick. Alternately, try/catch and reject(err) on catch.
    myMYSQL.db.query(
    q,
    function (error, results) {
    if (error)
    reject(error);
    resolve(results);
    });
    })
};

```

So, what I actually want to do, what's my issue?

I want to send the result of the query back to the client (the angular2 formular), and I was not being able to do it...

So after this really long post, I really appreciate if you read til here, and sorry for the complicated question!

PS: I know i explain myself really bad :(

Regards,
Daniel