What's the most efficient way to send data fetched from within a GET function to a PUG template? I've been pushing the data into an array and then sending that to the template, but this seems inefficient.
app.get('/tweet/:id', function(req, res) {
const id = req.params.id;
T.get('statuses/show/' + id, function(err, data, response) {
let stweet = [];
stweet.push(data.text);
});
res.render('tweet', {stweet: stweet});
});
This gets a Tweet ID from the url and uses it to retrieve the Tweet object. Is there some way I can pull "data" from T.get('statuses/show'...)
and display it directly on the PUG template?