Skip to content

Instantly share code, notes, and snippets.

@velopert velopert/sampleactionthunk.js Secret

Created Aug 11, 2016
Embed
What would you like to do?
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
You can’t perform that action at this time.