Reputation: 181
How can I get results of my function NODEJS in HTML there is my code:
var elasticsearch = require('elasticsearch');
var express = require('express');
var app = express();
var client = new elasticsearch.Client({
host: 'localhost:9200',
log: 'trace'
});
function getAllMetadata() {
client.search({
index: 'info',
scroll: '30s',
}, function getAll(error, response) {
response.hits.hits.forEach(function (body) {
allresp.push(body.hits);
})
console.log('Voilà le nombre de réponse : ' + allresp.length);
if (response.hits.total !== allresp.length) {
client.scroll({
scrollId: response._scroll_id,
scroll: '30s'
}, getAllMetadata);
}
});
}
getAllMetadata();
PS: PLZ how can i display my result "function" in HTML
Upvotes: 0
Views: 1021
Reputation: 3337
You need to make a view
and use a templating language like ejs
to use javascript variables in a view. The view will be a ejs
file which will be converter to html and rendered.
Here is a good example - https://github.com/chovy/express-template-demo
In that repo there is a index.ejs
which calls the function inspect(session)
Upvotes: 1