/sampleactionthunk.js Secret
Created
August 11, 2016 05:03
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 function searchRequest(username) { | |
return (dispatch) => { | |
dispatch(search); | |
if(username==='') { | |
return new Promise((resolve, reject)=> { | |
dispatch(searchSuccess([])); | |
resolve(); | |
}); | |
} | |
return axios.get('/api/account/search/' + username) | |
.then( | |
(response) => { | |
dispatch(searchSuccess(response.data)); | |
} | |
).catch( | |
(error) => { | |
dispatch(searchError()); | |
} | |
); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment