Data Issues Node.js (SQL Data)

Asked

Viewed 36 times

0

I have a question regarding receiving SQL data in a Javascript array. I have the login information and everything, related to the server, but the issue is not the connection, is to save the data in an array. Example: nameArray[username, email] (how to require this SQL info?)

app.get('/',(req, res) => {res.render('pages/home')})
function loginClient(){
    var conn = new sql.Connection(dbConfig);
    conn.connect().then(function(){
        var req = new sql.Request(conn);
        req.query("SELECT [CodCliSite],[RazaoSocial],[Email],[Pass] FROM [SITE].
        [dbo].[Clientes]").then(function(recordset){
            res.contentType('application/json');
            res.send(JSON.stringify(recordset));
            console.log(recordset);
            conn.close();
        }).catch(function(err){
            console.log(err);
            conn.close();
        });
    }).catch(function(err){
        console.log(err);
    });
}
return loginClient();
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.