payload

@lihbr/utils-nuxt.payload makes context.payload available in development (sorta).

Installation

Make sure you checked prerequisites before proceeding to installation~

Add @lihbr/utils-nuxt.payload dependency to your project:

yarn add --dev @lihbr/utils-nuxt.payload
npm install --save-dev @lihbr/utils-nuxt.payload

Then, add @lihbr/utils-nuxt.payload to the buildModules section of your nuxt.config.js file:

nuxt.config.js
export default {
  buildModules: [
    [
      "@lihbr/utils-nuxt.payload",
      {
        /* see configuration below for more */
      }
    ]
  ]
};

Usage

This module injects a $pagePayload method inside Nuxt.js context allowing you to resolve page payload provided through Nuxt.js generate routes payload options:

~/pages/index.vue
<script>
export default {
  async asyncData(context) {
    return await context.$pagePayload(context);
  }
};
</script>

Reference

Configuration

payloadBaseRoute

  • Type: String
  • Default: "/payload"

Base route from which payload will be served while in development.

module‏‏‎‏‏‎ options
{
  payloadBaseRoute: "/dev/payload"
}

Configuration Defaults

module‏‏‎ options
{
  payloadBaseRoute: "/payload"
}