node.js - NodeJs: Display function's result in html -


how can results of function nodejs in html there 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 display result "function" in html

you need make view , use templating language ejs use javascript variables in view. view ejs file converter html , rendered.

here example - https://github.com/chovy/express-template-demo

in repo there index.ejs calls function inspect(session)


Comments