【发布时间】:2019-01-27 19:53:07
【问题描述】:
我正在尝试使用 ES javascript api 从 Elastic Search 中获取数据并将其显示在我的 React Redux Redux-Saga 代码中。
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(),
}));
}
问题是我不知道如何让 yield 等待响应得到解决。 还有其他方法可以在 redux saga 和 es javascript-client 中使用 Promise 吗?
【问题讨论】:
标签: elasticsearch ecmascript-6 async-await redux-saga