Andrii
Andrii

Reputation: 324

Laravel + Vue ssr. Prefetch data

I'm trying to make application lavevel + vue with server side render. I have found this manual and it works perfect. Bu there is a small problem. I need fetch data before page loading for SEO issues and I found official vue ssr manual for prefetch. But it does not work. I only see error in the console
entry-client.js:6952 [Vue warn]: Cannot find element: #app.

my entry-server.js

import {createApp} from './app'
export default context => {
    return new Promise((resolve, reject) => {
        const {app, router, store} = createApp();
router.push(context.url)

router.onReady(() => {
  // This `rendered` hook is called when the app has finished rendering
  context.rendered = () => {
    context.state = store.state
  }

  resolve(app)
}, reject)
}).then(app => {
renderVueComponentToString(app, (err, res) => {
  print(res);
});
})
.catch((err) => {
  print(err);
})
}   

Are there any idea how solve this problem?

Looks like Promise does not work

Laravel 5.7 and Vue 2.6.6

Upvotes: 0

Views: 632

Answers (0)

Related Questions