MCPcopy Create free account
hub / github.com/basir/node-react-ecommerce / update

Function update

frontend/src/actions/userActions.js:9–24  ·  view source on GitHub ↗
({ userId, name, email, password })

Source from the content-addressed store, hash-verified

7} from "../constants/userConstants";
8
9const update = ({ userId, name, email, password }) => async (dispatch, getState) => {
10 const { userSignin: { userInfo } } = getState();
11 dispatch({ type: USER_UPDATE_REQUEST, payload: { userId, name, email, password } });
12 try {
13 const { data } = await Axios.put("/api/users/" + userId,
14 { name, email, password }, {
15 headers: {
16 Authorization: 'Bearer ' + userInfo.token
17 }
18 });
19 dispatch({ type: USER_UPDATE_SUCCESS, payload: data });
20 Cookie.set('userInfo', JSON.stringify(data));
21 } catch (error) {
22 dispatch({ type: USER_UPDATE_FAIL, payload: error.message });
23 }
24}
25
26const signin = (email, password) => async (dispatch) => {
27 dispatch({ type: USER_SIGNIN_REQUEST, payload: { email, password } });

Callers 1

submitHandlerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected