// Redux Saga
import { call, put } from 'redux-saga';
export function* fetchCartData(action) {
try {
const data = yield call(GET_CART_QUERY);
yield put({ type: "CART_SUCCESS", { data, isLoading: false }});
} catch (error) {
yield put({ type: 'CART_ERROR', { error, isLoading: false }});
}
}
function* watchFetchCartDataQuery() {
yield takeEvery('CART_REQUEST', fetchCartData);
}
(1) Listens for CART_REQUEST action
(2) Fires fetchCartData function