When my page gets requested, I have my server get data from a database. I've got that part figured out using an express route. Now I obviously want to use that data when generating the page. How do I do this?
app.get('/', function(req, res) {
console.log("GET REQUEST RECEIVED")
getData().then(function(result) {
data = result;
}, function(err) {
console.log(err);
});
//useDataInAppJs(data); ??????????????????????????
res.sendfile(__dirname + '/public/index.html')
})
I've been Googling a lot but just can't seem to figure out how to implement that commented line.
Aucun commentaire:
Enregistrer un commentaire