Added an example button that is included as another component to show how to add additional .vue includes into other Vue files
This commit is contained in:
parent
852a89ee71
commit
769b44c494
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
|
||||
<template>
|
||||
<button class="btn btn-primary">"Test Button"</button>
|
||||
</template>
|
||||
|
|
@ -1,20 +1,25 @@
|
|||
<template>
|
||||
<div class="container">
|
||||
<button class="btn btn-primary" @click="fetchCaddyConfig">Get Config</button>
|
||||
<br/>
|
||||
|
||||
<p> {{ myData }}</p>
|
||||
|
||||
<br />
|
||||
|
||||
<p>{{ caddyConfig }}</p>
|
||||
|
||||
<ButtonTest />
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ButtonTest from '../views/ButtonTest.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ButtonTest
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
myData: null,
|
||||
caddyConfig: null,
|
||||
isLoading: false,
|
||||
error: null
|
||||
};
|
||||
|
|
@ -26,14 +31,29 @@
|
|||
|
||||
let fetch_data = null;
|
||||
|
||||
try {
|
||||
const response = await fetch('http://localhost:2019/config/', {
|
||||
mode: 'cors',
|
||||
method: 'GET'
|
||||
});
|
||||
|
||||
if(!response.ok) {
|
||||
throw new Error('Error in fetch request');
|
||||
}
|
||||
|
||||
fetch_data = await response.json();
|
||||
this.caddyConfig = fetch_data;
|
||||
} catch (error) {
|
||||
this.error = "Could not fetch Caddy Config: " + error.message;
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
/*
|
||||
fetch('http://localhost:2019/config/', {
|
||||
mode: 'cors',
|
||||
method: 'GET'
|
||||
})
|
||||
//.then(response => console.log(response))
|
||||
.then(response => response.json())
|
||||
//then(responseJson => fetch_data = responseJson)
|
||||
//.then(data => console.log(data))
|
||||
.then(data => {
|
||||
fetch_data = data;
|
||||
this.myData = data;
|
||||
|
|
@ -43,8 +63,11 @@
|
|||
this.error = error;
|
||||
}
|
||||
);
|
||||
|
||||
*/
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.fetchCaddyConfig();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue