| 35 | } |
| 36 | |
| 37 | const register = (name, email, password) => async (dispatch) => { |
| 38 | dispatch({ type: USER_REGISTER_REQUEST, payload: { name, email, password } }); |
| 39 | try { |
| 40 | const { data } = await Axios.post("/api/users/register", { name, email, password }); |
| 41 | dispatch({ type: USER_REGISTER_SUCCESS, payload: data }); |
| 42 | Cookie.set('userInfo', JSON.stringify(data)); |
| 43 | } catch (error) { |
| 44 | dispatch({ type: USER_REGISTER_FAIL, payload: error.message }); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | const logout = () => (dispatch) => { |
| 49 | Cookie.remove("userInfo"); |