Skip to content

Instantly share code, notes, and snippets.

@Nosherwan
Created November 1, 2015 22:27
Show Gist options
  • Save Nosherwan/66f13ceb12ec6965433d to your computer and use it in GitHub Desktop.
Save Nosherwan/66f13ceb12ec6965433d to your computer and use it in GitHub Desktop.
React AuthService
import dataHelper from './DataHelper';
import LoginActions from '../actions/LoginActionCreators';
let AuthService = {
login: function (email, password) {
dataHelper.fetchPost('session', {email: email, password: password})
.then(resp => {
let {token,expires,user} = resp;
LoginActions.loginUser(token, expires,user);
console.log(token);
})
.catch(err => {
console.log(`Fetch post failed with error: ${err}`);
});
}
};
export default AuthService;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment