Reputation: 424
Following code is throwing error:
syncData().then((x) => yield put(loginUserSuccess(responseData)));
Error: The keyword 'yield' is reserved.
Sync data handles asynchronous operations of fetching data.I want to use yield put(provided by sagas.js) to trigger the action login user success after sync data has been performed.
Core of syncData function is as follows:
export default async function syncData(dataType) {
await Promise.all([syncData1(), syncData2()]);
}
Upvotes: 5
Views: 3659
Reputation: 74096
Try separating it like this, using the call
effect and then the put
effect:
try {
const res = yield call(syncData)
yield put(loginUserSuccess(res))
} catch(e) {
yield put(loginUserFail(e))
}
Upvotes: 7