Browse Source

Add qs

main
Haris Razis 4 years ago
parent
commit
535140eded
  1. 14078
      web/package-lock.json
  2. 1
      web/package.json
  3. 3
      web/src/store/index.ts
  4. 5
      web/src/views/Login.vue

14078
web/package-lock.json

File diff suppressed because it is too large

1
web/package.json

@ -12,6 +12,7 @@
"bootstrap": "^5.0.0-beta1",
"bulma": "^0.9.1",
"core-js": "^3.6.5",
"qs": "^6.5.2",
"vue": "^3.0.0",
"vue-class-component": "^8.0.0-0",
"vue-router": "^4.0.0-0",

3
web/src/store/index.ts

@ -1,5 +1,6 @@
import {createStore} from 'vuex'
import axios, {AxiosResponse} from "axios";
import qs from 'qs'
export default createStore({
state: {
@ -22,7 +23,7 @@ export default createStore({
actions: {
login({commit}, user: { username: string, password: string }) {
return new Promise((resolve, reject) => {
axios({url: 'http://localhost:8000/auth/login', data: {user}, method: 'GET'})
axios({method: 'post', url: 'http://localhost:8000/auth/login', data: qs.stringify({user})})
.then((resp: AxiosResponse) => {
commit("auth_success", user);
resolve(resp)

5
web/src/views/Login.vue

@ -53,10 +53,9 @@ export default class Login extends Vue {
private password = '';
private login() {
let email = this.username
let password = this.password
let user = {username: this.username, password: this.password}
this.$store.dispatch('login', {email, password})
this.$store.dispatch('login', user)
.then(() => this.$router.push('/dashboard'))
.catch((err: Error) => {
console.log(err)

Loading…
Cancel
Save