SHARE
TWEET

Untitled

a guest Sep 21st, 2019 95 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.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top