transformResponse property
TransformResponse?
transformResponse
final
Enables transformation of search network response before rendering them.
It is an asynchronous function which will accept an Elasticsearch response object as param and is expected to return an updated response as the return value. For example:
Future (Map elasticsearchResponse) async {
final ids = elasticsearchResponse['hits']['hits'].map(item => item._id);
final extraInformation = await getExtraInformation(ids);
final hits = elasticsearchResponse['hits']['hits'].map(item => {
final extraInformationItem = extraInformation.find(
otherItem => otherItem._id === item._id,
);
return Future.value({
...item,
...extraInformationItem,
};
}));
return Future.value({
...elasticsearchResponse,
'hits': {
...elasticsearchResponse.hits,
hits,
},
});
}
Implementation
final TransformResponse? transformResponse;