the merge project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

67 lines
1.4 KiB

4 years ago
<template>
<div>
<div v-if="!$store.state.player">
<input type="text" name="username" v-model="userNameInput"><br>
<button @click="createNewPlayer">Erstellen</button>
{{ response }}
</div>
<div v-else>
Hello, {{ $store.state.player.name }}
</div>
</div>
4 years ago
</template>
<script>
import axios from "axios";
4 years ago
export default {
name: 'HelloWorld',
data() {
return {
userNameInput: "",
response: ''
}
},
mounted() {
this.$store.commit('fetchUser');
},
methods: {
createNewPlayer() {
let component = this;
axios.post('http://api.luna-development.net/api/player/create', {
name: this.userNameInput.trim(),
game_id: 1
}).then((response) => {
console.log(response);
component.response = response.data;
localStorage.setItem('farmfresh_uuid', response.data.uuid);
}).catch((error) => {
console.log(error);
})
}
}
4 years ago
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
4 years ago
}
4 years ago
ul {
list-style-type: none;
padding: 0;
4 years ago
}
4 years ago
li {
display: inline-block;
margin: 0 10px;
4 years ago
}
4 years ago
a {
color: #42b983;
4 years ago
}
</style>