Created
November 18, 2017 17:10
-
-
Save lusan/9251dcbde0657db5af43849aed5c3541 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function getDeliveryAddress(some_state) { | |
return function(dispatch) { | |
axios(some_config_object) | |
.then(function(response) { | |
let deliveryDetailsState; | |
const deliveryAddressList = response.data.payload; | |
let updatedDeliveryAddressList = deliveryAddressList.map((item, index) => { | |
if(index !== 0) { | |
// This isn't the item we care about - keep it as-is | |
return item; | |
} | |
return { | |
...item, | |
listIndex: 0, | |
} | |
}); | |
dispatch({ | |
type: types.FETCH_DELIVERY_ADDRESS_LIST_SUCCESS, | |
some_state: some_state, | |
deliveryAddressList: updatedDeliveryAddressList, | |
}); | |
}) | |
.catch(function (error) { | |
logException(error); | |
return dispatch({ | |
type: types.FETCH_DELIVERY_ADDRESS_LIST_FAILURE, | |
some_state: some_state, | |
error | |
}); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment