2025-02-03 21:38:04 +01:00

38 lines
763 B
Vue

<script lang="ts">
import axios from 'axios'
import {callApi} from "@/helpers.ts";
import ErrorModal from "@/views/errorModal.vue";
export default {
components: {ErrorModal},
inject: ['callApi'],
data() {
return {
posts: null
}
},
methods: {
async getRandom() {
this.posts = await axios.get('http://localhost:8080/random')
},
async getUserInfo() {
//this.posts = await axios.get('http://localhost:8080/getUserInfo')
callApi("getUserInfo");
}
}
}
</script>
<template>
<button @click="getRandom()">get a random value</button>
<button @click="getUserInfo()">get user info</button>
<p> Res: {{this.posts?.data}}</p>
<error-modal error="test"></error-modal>
</template>
<style scoped>
</style>