I am facing problem with nodejs elasticsearch library. Below code is working and giving result if I remove console.log(hello); But if I add this then no error is coming. I am expecting error message of undefined variable "hello". I need to see error message for debugging purpose. What could be the reason?
var elasticsearch = require('elasticsearch');
var esClient = new elasticsearch.Client({
host: 'http://mywebsite.com',
// log: 'trace'
});
body = {};
esClient.search({
index: 'test',
type: 'data',
body: body
}).then(function (resp) {
console.log(hello);
console.log(resp);
});
Are you sure that the code reaches inside the then
function ? maybe search is throwing a error and you have no catch
block ???
try :
esClient.search({...})
.then(function (resp) {
console.log(hello);
console.log(resp);
})
.catch(function(error){
console.log(error);
});
see if you getting any error then ?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.