function* outputActionGetDepartments() {
  console.log("Monitoring The Saga for Get Departments Success");
  // Call the function that is return the Promise Object
  // Parameters
  // P1: A Function Callback that is returning the Promise Object
  // P2: (Overloads), the input parameters required by the Function Callback
  try {
    const response = yield call(getDepartments);
    console.log(
      `Received response $in Output Generator ${JSON.stringify(response.data)}`
    );
    // dispatch the output action
    yield put({
      type: "GET_DEPARTMENTS_SUCCESS", // output action type
      departments: response.data, // payload
      message: 'Successfully Received Departments'
    });
  } catch (e) {
    yield put({
      type: "GET_DEPARTMENTS_FAILED", // output action type
      message: `Failed to read departments ${e.message}`, // payload
    });
  }
}
// define Input and Output SAGA Generators
define Input and Output SAGA Generators
define Input and Output SAGA Generators
function* outputActionGetDepartments() {
  console.log("Monitoring The Saga for Get Departments Success");
  try {
    const response = yield call(getDepartments);
    console.log(
      `Received response $in Output Generator ${JSON.stringify(response.data)}`
    );
    yield put({
      type: "GET_DEPARTMENTS_SUCCESS", 
      departments: response.data, 
      message: 'Successfully Received Departments'
    });
  } catch (e) {
    yield put({
      type: "GET_DEPARTMENTS_FAILED", 
      message: `Failed to read departments ${e.message}`, 
    });
  }
}
function * outputActionGetDepartments ( ) { console . log ( "Monitoring The Saga for Get Departments Success" ) ; try { const response = yield call ( getDepartments ) ; console . log ( ` ${ JSON . stringify ( response . data ) } ` ) ; yield put ( { type : "GET_DEPARTMENTS_SUCCESS" , departments : response . data , message : 'Successfully Received Departments' } ) ; } catch ( e ) { yield put ( { type : "GET_DEPARTMENTS_FAILED" , message : ` ${ e . message } ` , } ) ; } }
define Input and Output SAGA Generators
define Input and Output SAGA Generators
// Call the function that is return the Promise Object // Parameters // P1: A Function Callback that is returning the Promise Object // P2: (Overloads), the input parameters required by the Function Callback // dispatch the output action // output action type // payload // output action type // payload