Skip to content

CmsBlock SSR fix with new serverPrefetch method #3910

@maikel-code

Description

@maikel-code

To make SSR finally work with cmsBlock:

  • just rename asyncData to serverPrefetch.
  • remove function params (as not needed) and outdated comments
  • change store.dispatch to this.$store.dispatch

And BAM, just some new vue magic and it works as intended
serverPrefetch is out there since vue version 2.6 and gives you access to this object
https://ssr.vuejs.org/api/#serverprefetch

serverPrefetch () {
    return new Promise((resolve, reject) => {
      this.$store.dispatch('cmsBlock/single', {
        value: this.identifier
      }).then(res => {
        return resolve(res)
      })
    })
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3: NormalPriority mark - normal prioritybugBug reports

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions