Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. export function login(login_email, login_password){
  2. const m = encodeURIComponent(login_email);
  3. const p = encodeURIComponent(login_password);
  4. const requestBody = `email=${m}&password=${p}`;
  5. return fetch('/api/users/login', {
  6. mode: 'no-cors',
  7. credentials: 'include',
  8. method: 'POST',
  9. headers: {
  10. 'Content-Type' : 'application/x-www-form-urlencoded',
  11. },
  12. body: requestBody
  13. }).then((response) => {
  14. setCookie('email', login_email);
  15. if(response.status==200){
  16. console.log("MYLOG status: " + response.status);
  17. getUserInfo(login_email);
  18. //alert('Login successfull!!!');
  19. myemail = login_email;
  20. loggedin = true;
  21. return true;
  22. }else{
  23. console.log("MYLOG status: " + response.status);
  24. alert('Login failed!!!');
  25. return false;
  26. }
  27. });
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement