Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   @Action({ commit: 'SET_USERNAME' })
  2.   async login(data) {
  3.     try {
  4.       // Send a login request to the server
  5.       const res = await fetch(`/api/login?username=${data.username}&password=${data.password}`);
  6.       // On success we can return the session cookie the server have given us
  7.       if (res.ok) {
  8.         return getCookie('sid');
  9.       }
  10.  
  11.       throw new Error(await res.text());
  12.     } catch (err) {
  13.       return err;
  14.     }
  15.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement