making sure type is defined and has postFlightRequest function (#17809)

This commit is contained in:
Peter Pisljar 2018-04-20 12:23:52 -05:00 committed by GitHub
parent 98f1220b79
commit 6068dcea82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -109,8 +109,10 @@ const CourierRequestHandlerProvider = function (Private, courier, timefilter) {
return _.cloneDeep(resp);
}).then(async resp => {
for (const agg of vis.getAggConfig()) {
const nestedSearchSource = new SearchSource().inherits(requestSearchSource);
resp = await agg.type.postFlightRequest(resp, vis.aggs, agg, nestedSearchSource);
if (_.has(agg, 'type.postFlightRequest')) {
const nestedSearchSource = new SearchSource().inherits(requestSearchSource);
resp = await agg.type.postFlightRequest(resp, vis.aggs, agg, nestedSearchSource);
}
}
searchSource.finalResponse = resp;