apiRequest
This commit is contained in:
37
src/components/forms/login.vue
Normal file
37
src/components/forms/login.vue
Normal file
@@ -0,0 +1,37 @@
|
||||
<template>
|
||||
<div class="LoginForm">
|
||||
<h2>Login</h2>
|
||||
<form @submit.prevent="login">
|
||||
<label>Username:</label><input type="text" v-model="username"><br>
|
||||
<label>Password:</label><input type="password" v-model="password"><br>
|
||||
<input type="submit" value="login">
|
||||
</form>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Axios from 'axios';
|
||||
|
||||
export default {
|
||||
name: 'LoginForm',
|
||||
data() {
|
||||
return {
|
||||
username: '',
|
||||
password: ''
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
login() {
|
||||
this.$store.dispatch("login", this.$data)
|
||||
.then(user => {
|
||||
console.log("---- user login --------");
|
||||
console.log(user);
|
||||
})
|
||||
.catch(error => {
|
||||
console.log("---- login error -------");
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -18,30 +18,26 @@ export default {
|
||||
return {
|
||||
columns: [
|
||||
{
|
||||
heading: 'col1',
|
||||
prop: 'prop1'
|
||||
heading: 'ID',
|
||||
prop: 'ID'
|
||||
},
|
||||
{
|
||||
heading: 'col2',
|
||||
prop: 'prop2'
|
||||
},
|
||||
{
|
||||
heading: 'col3',
|
||||
prop: 'prop3'
|
||||
},
|
||||
heading: 'Benutzername',
|
||||
prop: 'Username'
|
||||
}
|
||||
],
|
||||
rows: [
|
||||
{prop1: 'r1p1', prop2: 'r1p2', prop3: 'r1p3'},
|
||||
{prop1: 'r2p1', prop2: 'r2p2', prop3: 'r2p3'},
|
||||
{prop1: 'r3p1', prop2: 'r3p2', prop3: 'r3p3'},
|
||||
{prop1: 'r4p1', prop2: 'r4p2', prop3: 'r4p3'},
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
add() {
|
||||
this.rows.push({'prop1': 'test'});
|
||||
}
|
||||
created() {
|
||||
this.$store.dispatch('apiRequest', {
|
||||
endpoint: 'users'
|
||||
})
|
||||
.then(rows => this.rows = rows)
|
||||
.catch(error => {
|
||||
console.log(error);
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user