Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export function login(login_email, login_password){
- const m = encodeURIComponent(login_email);
- const p = encodeURIComponent(login_password);
- const requestBody = `email=${m}&password=${p}`;
- return fetch('/api/users/login', {
- mode: 'no-cors',
- credentials: 'include',
- method: 'POST',
- headers: {
- 'Content-Type' : 'application/x-www-form-urlencoded',
- },
- body: requestBody
- }).then((response) => {
- setCookie('email', login_email);
- if(response.status==200){
- console.log("MYLOG status: " + response.status);
- getUserInfo(login_email);
- //alert('Login successfull!!!');
- myemail = login_email;
- loggedin = true;
- return true;
- }else{
- console.log("MYLOG status: " + response.status);
- alert('Login failed!!!');
- return false;
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement