I have a restful API on my node js server that pulls down into from my SQL DB. When I launch the js code it works and prints to my console log...
How do I get a button on my HTML page to execute this API call? So when the user clicks the button it launches that code and pulls down the info from the DB
here is my code in my js file that grabs the info from my DB
app.get('/getcount/apples', function (req, res) {
sql.connect(config, function (err) {
if (err) console.log(err);
var resultapples = new sql.Request();
result.query("SELECT count FROM table12 WHERE fruit = 'apples'", function (err, result, fields) {
var arrayLength = result.length;
for (var i = 0; i < arrayLength; i++) {
console.log(result[i]["count"]);
};
});
});
});
So how do i get that to launch / execute from my html page