0👍
✅
That seems like a convoluted way to work and I wouldn’t follow that pattern. Why not create a component that takes an endpoint as a property <your-component endpoint="https://example.org/"></your-component>
and then component will do the call inside the create
method?
<template>
<div>
<img src="loading.jpg" v-show="loading" />
<!-- Content here -->
{{content}}
</div>
</template>
<script>
export default {
props: ['endpoint'],
data() {
return {
loading: true,
content: null
};
},
created() {
this.$http.get(this.endpoint).then(resp => {
this.content = resp.body;
this.loading = false;
});
}
}
</script>
Source:stackexchange.com