March 2018
Intermediate to advanced
364 pages
8h 21m
English
We need to expose a number of functions that can build objects for us containing a type and a payload property. Depending on what function we invoke, we will assign it with a different constant, and of course a different payload, if using one. The action creator fetchProducts() will create an object where only the type is set. This is followed by a fetchSuccessfully() action creator, which will be invoked once the data comes back from an endpoint. Lastly, we have the fetchError() action creator, which we will invoke if an error occurs:
// product/product.actions.tsimport { FETCHING_PRODUCTS_SUCCESSFULLY, FETCHING_PRODUCTS_ERROR, FETCHING_PRODUCTS } from "./product.constants";export const fetchSuccessfully = (products) => ...Read now
Unlock full access