enterprise axiosing
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Torma Kristóf 2022-05-21 22:14:29 +02:00
parent d36555d0e4
commit 78f06a3046
6 changed files with 46 additions and 12 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -1,22 +1,31 @@
<script lang="ts">
import axios from "axios";
import { defineComponent } from "vue";
import HHVDataService from "@/services/HHVDataService";
import type HHV from "@/types/HHV";
import type ResponseData from "@/types/ResponseData";
export default {
export default defineComponent({
data() {
return {
weeknumber: 0,
weeknumber: {} as HHV,
};
},
async created() {
try {
const res = await axios.get("https://hanyadikhetvan.tormakristof.eu/");
this.weeknumber = res.data;
} catch (error) {
console.log(error);
methods: {
retrieveWeekNumber() {
HHVDataService.getWeekNumber()
.then((response: ResponseData) => {
this.weeknumber = response.data;
console.log(response.data);
})
.catch((e: Error) => {
console.log(e);
});
}
}
}
},
mounted() {
this.retrieveWeekNumber();
},
});
</script>
<template>

9
src/http-common.ts Normal file
View File

@ -0,0 +1,9 @@
import axios from "axios";
import type { AxiosInstance } from "axios";
const apiClient: AxiosInstance = axios.create({
baseURL: "https://hanyadikhetvan.tormakristof.eu",
});
export default apiClient;

View File

@ -0,0 +1,10 @@
import http from "@/http-common";
/* eslint-disable */
class HHVDataService {
getWeekNumber(): Promise<any> {
return http.get("/");
}
}
export default new HHVDataService();

3
src/types/HHV.ts Normal file
View File

@ -0,0 +1,3 @@
export default interface HHV {
id: number;
}

View File

@ -0,0 +1,3 @@
export default interface ResponseData {
data: any;
}