Skip to content

Instantly share code, notes, and snippets.

@lusan
Created November 18, 2017 17:10
Show Gist options
  • Save lusan/9251dcbde0657db5af43849aed5c3541 to your computer and use it in GitHub Desktop.
Save lusan/9251dcbde0657db5af43849aed5c3541 to your computer and use it in GitHub Desktop.
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