How to use @kentico/kontent-delivery - 1 common examples

To help you get started, we’ve selected a few @kentico/kontent-delivery examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Domitnator / kentico-kontent-nuxt-module / lib / templates / plugin.template.js View on Github external
export default (ctx, inject) => {
  // Create new  delivery client Instance
  let settings = JSON.parse('KENTICOOPTIONS')

  // Add tracking header
  settings = Object.assign({}, settings, {
    globalQueryConfig: {
      customHeaders: [
        { header: 'X-KC-SOURCE', value: 'kentico-kontent-nuxt-module' }
      ]
    }
  })

  const deliveryClient = new DeliveryClient(settings)

  const cacheService = new CacheService([])

  deliveryClient.viaCache = function (query, seconds, cacheKey) {
    return cacheService.viaCache(query, seconds, cacheKey, process.server)
  }

  // Inject the deliveryClient to the context as $deliveryClient
  ctx.$deliveryClient = deliveryClient
  inject('deliveryClient', deliveryClient)
}

@kentico/kontent-delivery

Official Kentico Kontent Delivery API SDK

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis

Popular @kentico/kontent-delivery functions