Skip to content

Instantly share code, notes, and snippets.

@sharvit
Last active April 30, 2019 11:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharvit/915decb9a3599ed1161097f4ee988fd3 to your computer and use it in GitHub Desktop.
Save sharvit/915decb9a3599ed1161097f4ee988fd3 to your computer and use it in GitHub Desktop.
API request action
export const fetchTasksSummary = time => {
const hours = timeToHoursNumber(time);
return {
type: API_REQUEST,
action: ACTIONS.GET,
url: `/foreman_tasks/tasks/summary/${hours}`,
subType: FOREMAN_TASKS_DASHBOARD_FETCH_TASKS_SUMMARY,
normalizeResponse: (data) => data.results[0],
normalizeError: error => error.message,
onError: error => console.log(error),
}
};
// another option
export const fetchTasksSummary = time => {
const hours = timeToHoursNumber(time);
return ActionsAPI.get({
url: `/foreman_tasks/tasks/summary/${hours}`,
type: FOREMAN_TASKS_DASHBOARD_FETCH_TASKS_SUMMARY,
normalizeResponse: (data) => data.results[0],
normalizeError: error => error.message,
onError: error => console.log(error),
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment