function registrationFetchData(newUser) {
  // Post Body Here
  const postRequest = {
    method: 'POST',
    name: newUser.name,
    email: newUser.email,
    password: newUser.password,
    passwordConfirm: newUser.passwordConfirm,
    headers: {
      Accept: 'application/json',
      'Content-Type': 'application/json',
    },
  };
  // Dispatch Loading Status to Component
  return async (dispatch) => {
    /*
   Reset all Register Dispatch Actions
   to default and the Loading State to true
   */
    dispatch(registrationRequested());
    // POST DATA to API HEre
    await axios.post('https://akin-react-auth-api.herokuapp.com/user/register', postRequest)
      .then((response) => {
        dispatch(registrationIsLoading(false));
        // Get Reponse
        const apiResponse = response.data;
        // If response is not 200
        if (apiResponse.status !== 200) {
          dispatch(registrationHasErrored(true));
          dispatch(registrationErrorMessage(apiResponse.message));
        } else if (apiResponse.status === 200) {
        // Dispatch User Authenticated Action if succesful
          return dispatch(registrationSuccess(true));
        }
      })
      .catch(() => {
        dispatch(registrationHasErrored(true));
      });
  };
}
// Action to Fetch data from APi here
Action to Fetch data from APi here
Action to Fetch data from APi here
function registrationFetchData(newUser) {
  const postRequest = {
    method: 'POST',
    name: newUser.name,
    email: newUser.email,
    password: newUser.password,
    passwordConfirm: newUser.passwordConfirm,
    headers: {
      Accept: 'application/json',
      'Content-Type': 'application/json',
    },
  };
  return async (dispatch) => {
    dispatch(registrationRequested());
    await axios.post('https://akin-react-auth-api.herokuapp.com/user/register', postRequest)
      .then((response) => {
        dispatch(registrationIsLoading(false));
        const apiResponse = response.data;
        if (apiResponse.status !== 200) {
          dispatch(registrationHasErrored(true));
          dispatch(registrationErrorMessage(apiResponse.message));
        } else if (apiResponse.status === 200) {
          return dispatch(registrationSuccess(true));
        }
      })
      .catch(() => {
        dispatch(registrationHasErrored(true));
      });
  };
}
function registrationFetchData ( newUser ) { const postRequest = { method : 'POST' , name : newUser . name , email : newUser . email , password : newUser . password , passwordConfirm : newUser . passwordConfirm , headers : { Accept : 'application/json' , 'Content-Type' : 'application/json' , } , } ; return async ( dispatch ) => { dispatch ( registrationRequested ( ) ) ; await axios . post ( 'https://akin-react-auth-api.herokuapp.com/user/register' , postRequest ) . then ( ( response ) => { dispatch ( registrationIsLoading ( false ) ) ; const apiResponse = response . data ; if ( apiResponse . status !== 200 ) { dispatch ( registrationHasErrored ( true ) ) ; dispatch ( registrationErrorMessage ( apiResponse . message ) ) ; } else if ( apiResponse . status === 200 ) { return dispatch ( registrationSuccess ( true ) ) ; } } ) . catch ( ( ) => { dispatch ( registrationHasErrored ( true ) ) ; } ) ; } ; }
Action to Fetch data from APi here
Action to Fetch data from APi here
// Post Body Here // Dispatch Loading Status to Component /*
   Reset all Register Dispatch Actions
   to default and the Loading State to true
   */ // POST DATA to API HEre // Get Reponse // If response is not 200 // Dispatch User Authenticated Action if succesful