I wrote this function:
_sendGetRequest : function (query) {
http.get({
host: elasticIp,
port: elasticPort,
path: "/logstash-2016.09.19/_search?source=" +
query
}, function (response) {
var body = '';
response.on('data', function (d) {
body += d;
});
response.on('end', function () {
//return body
});
});
}
I want _sendGetRequest to return response.body only when http request ends How can I do that with/without promise?