I'm trying to use ES javascript api to get data from Elastic Search and show it in my React Redux Redux-Saga code.
function* getData() {
const response = async () => await client.msearch({
body: [
// match all query, on all indices and types
{},
{ query: { match_all: {} } },
// query_string query, on index/mytype
{ index: 'myindex', type: 'mytype' },
{ query: { query_string: { query: '"Test 1"' } } },
],
});
yield put(Success({
Data: response(),
}));
}
The problem is I don't know how to make the yield wait for the response to be resolved. Is there any other way to use a promise inside redux saga and es javascript-client ?