I want to use Vue in server side rendering, but the content data inside template have to request from the other CMS server.
<template>
<h1>{{ content.heading }}</h1>
</template>
<script>
export default {
data() {
return {
content: {
heading: ''
}
}
},
created() {
axios
.get(CONTENT_RESOURCE)
.then(content => this.content = content);
}
}
</script>
Due to axios.get
is an async request, server will send empty content before request complete.
Use curl to request content:
curl 'URL';
# It got <h1></h1>,
# but I want <h1>Something here</h1>
How do I make sure it can render with CMS content data in server side?
curl
, it just got<h1></h1>
, not<h1>Page Title</h1>
– Knovour