Created
November 1, 2015 22:27
-
-
Save Nosherwan/66f13ceb12ec6965433d to your computer and use it in GitHub Desktop.
React AuthService
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
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; |