September 2018
Intermediate to advanced
302 pages
7h 17m
English
We have already tried generators and we have successfully fetched tasks using them. Now, we will repeat the process, but with a slightly different goal: to fetch the data of a single task. To achieve this, I have made a few changes to the code base and prepared the parts of code to keep your eyes on generators only:
// src/Chapter 8/Example 1/src/features/tasks/sagas/fetchTask.js// ^ fully functional example with TaskDetails pageexport function* fetchTask(action) { const task = yield call(apiFetch, `tasks/${action.payload.taskId}`); if (task.error) { yield put(ActionCreators.fetchTaskError(task.error)); } else { const json = yield call([task.response, 'json']); yield put(ActionCreators. ...
Read now
Unlock full access