Created
July 10, 2020 06:40
-
-
Save mcjcloud/f95f9af99d5c295db7cc262962465bca to your computer and use it in GitHub Desktop.
Asterisk Medium Article: uncompleteTodo
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 const uncompleteTodo = (guid: string) => async (dispatch: Dispatch) => { | |
dispatch({ type: "TODO_UNCOMPLETED_STARTED" }) | |
const response = await fetch(`${API_ENDPOINT}/todo/${guid}/uncomplete`, { | |
method: "POST", | |
headers: { | |
"Content-Type": "application/json", | |
}, | |
}).then(r => r.json()) | |
if (!!response && !!response?.todo) { | |
dispatch({ type: "TODO_UNCOMPLETED", payload: { todo: response.todo } }) | |
} else { | |
dispatch({ type: "TODO_ERRORED", payload: { uncompleteError: response?.error ?? "Error uncompleting Todo item" } }) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment