mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 21:49:01 +01:00
Add FetchData component
This commit is contained in:
parent
d678e7d594
commit
98cd8383a1
@ -27,6 +27,8 @@ window.axios.defaults.headers.common = {
|
||||
* or customize the JavaScript scaffolding to fit your unique needs.
|
||||
*/
|
||||
|
||||
Vue.component('fetch-data', require('./components/FetchData'));
|
||||
|
||||
new Vue({
|
||||
el: '#app',
|
||||
data () {
|
||||
@ -48,5 +50,5 @@ window.axios.defaults.headers.common = {
|
||||
'invite-team': require('./components/dashboard/InviteTeam'),
|
||||
'metric-chart': require('./components/status-page/Metric'),
|
||||
}
|
||||
})
|
||||
});
|
||||
})()
|
||||
|
31
resources/assets/js/components/FetchData.vue
Normal file
31
resources/assets/js/components/FetchData.vue
Normal file
@ -0,0 +1,31 @@
|
||||
<script>
|
||||
export default {
|
||||
props: ['url'],
|
||||
data() {
|
||||
return {
|
||||
loaded: false,
|
||||
response: null,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
axios.get(this.url)
|
||||
.then((response) => {
|
||||
this.response = response
|
||||
this.loaded = true
|
||||
})
|
||||
},
|
||||
render() {
|
||||
if (!this.loaded) {
|
||||
return this.$scopedSlots.default({
|
||||
loading: true,
|
||||
response: null,
|
||||
})
|
||||
}
|
||||
|
||||
return this.$scopedSlots.default({
|
||||
loading: false,
|
||||
response: this.response.data,
|
||||
})
|
||||
},
|
||||
}
|
||||
</script>
|
Loading…
x
Reference in New Issue
Block a user