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

Function createUserAddress

frontend/src/actions/userActions.js:377–413  ·  view source on GitHub ↗
(addressData)

Source from the content-addressed store, hash-verified

375
376// create user address
377export const createUserAddress = (addressData) => async (dispatch, getState) => {
378
379 try {
380 dispatch({
381 type: CREATE_USER_ADDRESS_REQUEST
382 })
383
384 const {
385 userLoginReducer: { userInfo }
386 } = getState()
387
388 const config = {
389 headers: {
390 "Content-Type": "application/json",
391 Authorization: `Bearer ${userInfo.token}`
392 }
393 }
394
395 // call api
396 const { data } = await axios.post(
397 "/account/create-address/",
398 addressData,
399 config
400 )
401
402 dispatch({
403 type: CREATE_USER_ADDRESS_SUCCESS,
404 payload: data
405 })
406
407 } catch (error) {
408 dispatch({
409 type: CREATE_USER_ADDRESS_FAIL,
410 payload: error.response && error.response.data.details ? error.response.data.details : error.message
411 })
412 }
413}
414
415
416// update user address

Callers 1

addressSubmitHandlerFunction · 0.90

Calls 1

postMethod · 0.45

Tested by

no test coverage detected