Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Action({ commit: 'SET_USERNAME' })
- async login(data) {
- try {
- // Send a login request to the server
- const res = await fetch(`/api/login?username=${data.username}&password=${data.password}`);
- // On success we can return the session cookie the server have given us
- if (res.ok) {
- return getCookie('sid');
- }
- throw new Error(await res.text());
- } catch (err) {
- return err;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement