import axios from "axios";
export const postSignUp = (state) => {
return async (dispatch) => {
const config = {
header: {
"Content-Type": "application/json",
},
};
dispatch({ type: "SET_LOADER" });
try {
const { data } = await axios.post("/user/signup", state, config);
dispatch({ type: "CLOSE_LOADER" });
localStorage.setItem("MyToken", data.token);
dispatch({ type: "SET_TOKEN", token: data.token });
} catch (error) {
dispatch({ type: "CLOSE_LOADER" });
dispatch({
type: "SIGNUP_ERRORS",
signupError: error.response.data.errors,
});
console.log(error.response.data.errors);
}
};
};