payload

lihbr utils for Nuxt.js

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

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"
}
Edit this page on GitHub Updated at Tue, Apr 13, 2021