Advertisement
Guest User

login.vue

a guest
Apr 12th, 2019
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var swal = this.$swal;
  2.  
  3.           swal({
  4.             title: "Sign In ..",
  5.             allowOutsideClick: false,
  6.             showConfirmButton: false,
  7.             width: 400,
  8.             onOpen: () => {
  9.                window.localStorage.removeItem('user');
  10.               swal.showLoading();
  11.               axios
  12.                 .post(
  13.                   baseUrl + "/admin/login",
  14.                   {
  15.                     username: this.username,
  16.                     password: this.password
  17.                   },
  18.                   {
  19.                     headers: {
  20.                       "Content-Type": "application/json"
  21.                     }
  22.                   }
  23.                 )
  24.                 .then(response => {
  25.                   swal.close();
  26.                   localStorage.setItem(
  27.                     "user",
  28.                     JSON.stringify(response.data.results[0])
  29.                   );
  30.                   console.log(response.data.results[0]);
  31.                   window.location.reload();
  32.                   this.$router.push("/buku-tamu");
  33.                 })
  34.                 .catch(a => {
  35.                   swal.close();
  36.                   this.login = false;
  37.                   this.$swal({
  38.                     width: 400,
  39.                     type: "error",
  40.                     title: "Oops...",
  41.                     text: a.response.data.message,
  42.                     footer: "<a href>Forgot Password?</a>"
  43.                   });
  44.  
  45.                   (this.username = null),
  46.                     (this.password = null),
  47.                     this.error.push(e);
  48.                   console.log(e);
  49.                 });
  50.             }
  51.           }).then(result => {});
  52.         })
  53.         .catch(() => {});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement