How to set header from asyncData in NuxtJS

Category:
Author: zemna
Date: April 17, 2021
Share this:

You can access asyncData if you you head() function.

Use 'head()' function in your script, not 'head:'

export default {
  head() {
    return {
      title: this.tag.name
    }
  },
  async asyncData({ $content, params }) {
    const tag = await $content('tags', params.slug).fetch()

    return {
      tag
    }
  }
}
Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *

Let's connect and create
something awesome together!
2023 - Copyright, All Rights Reserved, Made by ZEMNA.NET with ❤️
crossmenu linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram