hi @dmt876
function beforeRender(req, res, done) {
var config = require('Configuration.json');
var elasticsearch = require('@elastic/elasticsearch');
var esClient = new elasticsearch.Client({
node: config.esURL,
auth: {
username: config.user,
password: config.password
}
});
// simple test for ES connectivity - fetch cluster health
esClient.cluster.health({},function(err,resp,status) {
console.log("-- Client Health -- resp",resp);
console.log("-- Client Health -- err",err);
console.log("-- Client Health -- status",status);
});
the script in 2.11.0 has two forms, one is based on promises and async/await style, and the other is based on the callback style. to use one form or the other depends on how you define the beforeRender function.
you are currently defining the beforeRender with 3 arguments, which means you are choosing the callback style, and when you use the callback style you need to use that third param done to signal the script that it finished.
for example, I know that your script is longer than just this fragment of code, but I will update it to reflect the usage of the done parameter.
function beforeRender(req, res, done) {
var config = require('Configuration.json');
var elasticsearch = require('@elastic/elasticsearch');
var esClient = new elasticsearch.Client({
node: config.esURL,
auth: {
username: config.user,
password: config.password
}
});
// simple test for ES connectivity - fetch cluster health
esClient.cluster.health({},function(err,resp,status) {
console.log("-- Client Health -- resp",resp);
if (err) {
console.log("-- Client Health -- err",err);
return done(err)
}
console.log("-- Client Health -- status",status);
done()
});
}
you should update the rest of your code to properly call done either with an error or with no param when it is completed