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();
The best would be to save the data to an object or an object array
JSON
– Costamilam
Possible duplicate of Store SQL data in a Javascript array
– NoobSaibot