Created
October 16, 2018 04:09
-
-
Save tpai/90507255db14ae777fb3c9e3a4e2ebe1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const updateTitle = title => { | |
| return async dispatch => { | |
| dispatch({ type: UPDATE_TITLE }); | |
| try { | |
| const res = await fetch(url, { | |
| method: 'PUT', | |
| headers: { | |
| 'Accept': 'application/json', | |
| 'Content-Type': 'application/json' | |
| }, | |
| body: { title } | |
| }); | |
| const json = await res.json(); | |
| dispatch({ type: UPDATE_TITLE_SUCCESS, data: json }); | |
| } catch(err) { | |
| dispatch({ type: UPDATE_TITLE_FAILED }); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment