how to call context api login function in ant design onFinish method

Viewed 31
context api function

const login = ({ data }) => {
    console.log(data);
};

this is my reducer i will update state after login process success

switch (action.type) {
    case LOGIN: {
      return { ...state };
    }
    default:
     return {...state};
}

this is ant desing form submit

const loginProcess = async (data) => {
    try {
      const response = await axios.post(
        'http://127.0.0.1:8000/api/login',
        data,
        {
          headers: {
            'Content-Type': 'application/json',
          },
        }
      );
      // dispatch({ type: LOGIN ,payload:response.data});
      console.log(response.data);
    } catch (error) {
      // Handle Error Here
      message.error(error.response.data.message);
    }
  };



  const onFinish = (values) => {
    loginProcess(values);
  };

here i want to fire function/want to call context function after login success

0 Answers
Related