2.2.1 • Published 5 years ago

kenticocloud-nuxt-module v2.2.1

Weekly downloads
36
License
ISC
Repository
github
Last release
5 years ago

CircleCI semantic-release NPM

kenticocloud-nuxt-module

Add kentico cloud super power to your nuxt app

Features

The module makes it easy to do delivery client api calls via the Kentico Cloud Delivery SDK.

Quick start

  • Install via npm
npm i kenticocloud-nuxt-module --save
npm i rxjs --save (because this is a peer dependency of the Kentico Cloud Delivery SDK)
  • Add kenticocloud-nuxt-module to modules section of nuxt.config.js
  /*
  ** Nuxt.js modules
  */
  modules: [
    'kenticocloud-nuxt-module'
  ],
  kenticocloud: {
    projectId: 'xxxx-xxx-xxxx-xxxx-xxxxx',
    enableAdvancedLogging: false,
    previewApiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
    enablePreviewMode: true,
    baseUrl: 'https://custom.uri/api/KenticoCloudProxy',
    securedApiKey: 'xxx',
    enableSecuredMode: true
  },
  • $deliveryClient is now globally available.
 this.$deliveryClient.items()
    .type('page')
    .toPromise()
    .then(response => console.log('DeliveryClient Response', response));

Note:

By default Nuxt can only work with promises. Therefor you always use the "toPromise" method provided by the Kentico Cloud Delivery SDK! RxJs operator's are not supported at the moment.

Caching

API calls can be "cached" (they will be stored in memory) client side via the "viaCache" method.

 const query =  this.$deliveryClient.items().type('page');
 const cacheSeconds = 30;
 this.$deliveryClient.viaCache(query, cacheSeconds)
        .then(response => console.log('DeliveryClient Response', response));

Extending

If you need to customize the Kentico Cloud Delivery SDK by registering interceptors and changing global config, you have to create a nuxt plugin.

nuxt.config.js

{
  modules: [
    'kenticocloud-nuxt-module',
  ],

  plugins: [
    '~/plugins/kenticocloudNuxtModule'
  ]
}

plugins/kenticocloudNuxtModule.js

export default function ({ store, $deliveryClient }) {
    $deliveryClient.config.globalHeaders = (queryConfig) => {
        let headers = [];
        headers.push({header: 'Authorization', value: 'bearer ' + store.state.token });
        return headers;
      }
  }
2.2.1

5 years ago

2.1.0

5 years ago

2.0.1

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.0-beta

6 years ago