Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // dispatching action in function
- const { dispatch, acctions, assignment } = this.props;
- const assignmentId = assignment._id;
- dispatch(acctions.getLiveLocation(assignmentId));
- // in assigment reducer function
- export function getLiveLocation(id) {
- return {
- type: GET_LIVE_LOCATION_DATA,
- promise: {
- method: 'GET',
- path: `/assignment/trackingInfo?assignmentId=${id}`,
- },
- };
- }
- // switch case in assignment reducer
- case GET_LIVE_LOCATION_DATA_REQUEST:
- console.log('request');
- return {
- ...state,
- requesting: true,
- };
- case GET_LIVE_LOCATION_DATA_SUCCESS:
- console.log('response');
- return {
- ...state,
- liveLocationData: action.response.data,
- error: undefined,
- requesting: false,
- };
- case GET_LIVE_LOCATION_DATA_FAILURE:
- console.log('failure');
- return {
- ...state,
- error: action.response.error,
- requesting: false,
- };
Add Comment
Please, Sign In to add comment