Nodejs API: Query with two parameters in WHERE statement

Viewed 152

I am coding a react native app and have a query that contains two parameters in the WHERE statement. The problem is, I don't know how to route it properly. I already tried routing with one parameter, and it works. But, when I try using two parameters, it can't actually get any data from the database.

Here are my codes:

Routing:

router.route('/users/user=:username').get((request,response) => {
    operations.getUsers(request.params.username).then(result => {
        response.json(result[0])
    })
})

Query:

let pool = await sql.connect(config);
        let users = await pool.request()
            .input('username', sql.VarChar, user)
            .input('password', sql.Char, pass)
            .query('SELECT * FROM Users_temp WHERE username = @username');
        return users.recordsets;
1 Answers

you can fix the problem by updating the query like this

 .query('SELECT * FROM Users_temp WHERE username = @username and password = @password');
Related