Skip to content

Instantly share code, notes, and snippets.

@bnhansn
Created October 22, 2016 18:54
Show Gist options
  • Save bnhansn/cf021baa8231458f6b807a3714260a79 to your computer and use it in GitHub Desktop.
Save bnhansn/cf021baa8231458f6b807a3714260a79 to your computer and use it in GitHub Desktop.
// top of file
import api from '../api';
// bottom of file
export function loadOlderMessages(roomId, params) {
return (dispatch) => {
dispatch({ type: 'FETCH_MESSAGES_REQUEST' });
return api.fetch(`/rooms/${roomId}/messages`, params)
.then((response) => {
dispatch({ type: 'FETCH_MESSAGES_SUCCESS', response });
})
.catch(() => {
dispatch({ type: 'FETCH_MESSAGES_FAILURE' });
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment