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

Function deleteUserAddress

frontend/src/actions/userActions.js:456–490  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

454
455// delete user address
456export const deleteUserAddress = (id) => async (dispatch, getState) => {
457 try {
458 dispatch({
459 type: DELETE_USER_ADDRESS_REQUEST
460 })
461
462 const {
463 userLoginReducer: { userInfo }
464 } = getState()
465
466 const config = {
467 headers: {
468 "Content-Type": "application/json",
469 Authorization: `Bearer ${userInfo.token}`
470 }
471 }
472
473 // call api
474 const { data } = await axios.delete(
475 `/account/delete-address/${id}/`,
476 config
477 )
478
479 dispatch({
480 type: DELETE_USER_ADDRESS_SUCCESS,
481 payload: data
482 })
483
484 } catch (error) {
485 dispatch({
486 type: DELETE_USER_ADDRESS_FAIL,
487 payload: error.response && error.response.data.details ? error.response.data.details : error.message
488 })
489 }
490}
491
492// get all orders
493export const getAllOrders = () => async (dispatch, getState) => {

Callers 1

confirmDeleteFunction · 0.90

Calls 1

deleteMethod · 0.45

Tested by

no test coverage detected