Skip to content

Instantly share code, notes, and snippets.

@sivadass
Created January 31, 2018 11:23
Show Gist options
  • Save sivadass/ab144f12095161494b3af10172f891a1 to your computer and use it in GitHub Desktop.
Save sivadass/ab144f12095161494b3af10172f891a1 to your computer and use it in GitHub Desktop.
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