Created
January 31, 2018 11:23
-
-
Save sivadass/ab144f12095161494b3af10172f891a1 to your computer and use it in GitHub Desktop.
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 request from 'superagent'; | |
export const GET_LOGGED_USER = 'GET_LOGGED_USER'; | |
export const SET_LOGGED_USER = 'SET_LOGGED_USER'; | |
export const login = (response) => ({ | |
type: SET_LOGGED_USER, | |
logged: true, | |
payload: response | |
}) | |
export const getLoggedUser = () => ({ | |
type: GET_LOGGED_USER, | |
pending: false | |
}) | |
export function getLoggedUserAsync() { | |
return dispatch => { | |
setTimeout(() => { | |
dispatch(getLoggedUser()); | |
}, 500); | |
}; | |
} | |
export function loginAsync(username, password) { | |
return dispatch => { | |
getLoggedUserAsync(); | |
// axios({ | |
// method: 'post', | |
// url: 'https://srvy-app.appspot.com/api/v1/signin', | |
// headers: {'Content-Type': 'application/json'}, | |
// data: { | |
// username: username, | |
// password: password | |
// } | |
// }) | |
// .then(function (response) { | |
// console.log(response); | |
// let userData = response.data.profile | |
// dispatch(login(userData)); | |
// }) | |
// .catch(function (error) { | |
// console.log("Invalid username or password"); | |
// console.log(error); | |
// }); | |
// Added after login service is not working | |
let userData = { | |
fistName: "Sivadass N" | |
} | |
dispatch(login(userData)); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment