0👍
✅
Solved the issue this way
const Vue = require('vue');
const renderer = require('vue-server-renderer').createRenderer();
const app = new Vue({
data: {
title: 'this is a test title',
Name: 'Name',
Sender: 'Someone'
},
template: require('fs').readFileSync('./index.template.html', 'utf-8')
});
let sent;
let context = {
title: 'this is a test title',
Name: 'Name',
Sender: 'Someone'
};
renderer.renderToString(app, context, (err, html) => {
if (err) {
res.status(500).end('Internal Server Error');
return
}
sent = html;
sails.log(sent);
});
The data can be accessed in the index.template.html by using the “Mustache” syntax like so {{ title }}
Source:stackexchange.com