MCPcopy Create free account
hub / github.com/YashMarmat/FullStack_Ecommerce_App / register

Function register

frontend/src/actions/userActions.js:104–137  ·  view source on GitHub ↗
(username, email, password)

Source from the content-addressed store, hash-verified

102
103// register
104export const register = (username, email, password) => async (dispatch) => {
105 try {
106 dispatch({ type: USER_REGISTER_REQUEST })
107
108 const config = {
109 headers: {
110 'Content-type': 'application/json'
111 }
112 }
113
114 const { data } = await axios.post(`/account/register/`,
115 { 'username': username, 'email': email, 'password': password },
116 config
117 )
118
119 dispatch({
120 type: USER_REGISTER_SUCCESS,
121 payload: data
122 })
123
124 dispatch({
125 type: USER_LOGIN_SUCCESS,
126 payload: data
127 })
128
129 localStorage.setItem('userInfo', JSON.stringify(data))
130 }
131 catch (error) {
132 dispatch({
133 type: USER_REGISTER_FAIL,
134 payload: error.response && error.response.data.detail ? error.response.data.detail : error.message
135 })
136 }
137}
138
139// check token validation
140export const checkTokenValidation = () => async (dispatch, getState) => {

Callers 1

submitHandlerFunction · 0.90

Calls 1

postMethod · 0.45

Tested by

no test coverage detected