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

Function updateUserAddress

frontend/src/actions/userActions.js:417–452  ·  view source on GitHub ↗
(id, addressData)

Source from the content-addressed store, hash-verified

415
416// update user address
417export const updateUserAddress = (id, addressData) => async (dispatch, getState) => {
418 try {
419 dispatch({
420 type: UPDATE_USER_ADDRESS_REQUEST
421 })
422
423 const {
424 userLoginReducer: { userInfo }
425 } = getState()
426
427 const config = {
428 headers: {
429 "Content-Type": "application/json",
430 Authorization: `Bearer ${userInfo.token}`
431 }
432 }
433
434 // call api
435 const { data } = await axios.put(
436 `/account/update-address/${id}/`,
437 addressData,
438 config
439 )
440
441 dispatch({
442 type: UPDATE_USER_ADDRESS_SUCCESS,
443 payload: data
444 })
445
446 } catch (error) {
447 dispatch({
448 type: UPDATE_USER_ADDRESS_FAIL,
449 payload: error.response && error.response.data.details ? error.response.data.details : error.message
450 })
451 }
452}
453
454
455// delete user address

Callers 1

addressSubmitHandlerFunction · 0.90

Calls 1

putMethod · 0.45

Tested by

no test coverage detected