enterprise axiosing
All checks were successful
continuous-integration/drone/push Build is passing

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"> <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() { data() {
return { return {
weeknumber: 0, weeknumber: {} as HHV,
}; };
}, },
methods: {
async created() { retrieveWeekNumber() {
try { HHVDataService.getWeekNumber()
const res = await axios.get("https://hanyadikhetvan.tormakristof.eu/"); .then((response: ResponseData) => {
this.weeknumber = res.data; this.weeknumber = response.data;
} catch (error) { console.log(response.data);
console.log(error); })
.catch((e: Error) => {
console.log(e);
});
} }
} },
} mounted() {
this.retrieveWeekNumber();
},
});
</script> </script>
<template> <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;
}