How to use the contentful-sdk-core.getUserAgentHeader function in contentful-sdk-core

To help you get started, we’ve selected a few contentful-sdk-core 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 contentful / contentful-management.js / lib / contentful-management.js View on Github external
export function createClient (params) {
  const defaultParameters = {
    defaultHostname: 'api.contentful.com',
    defaultHostnameUpload: 'upload.contentful.com'
  }
  const userAgentHeader = getUserAgentHeader(`contentful-management.js/${__VERSION__}`,
    params.application,
    params.integration,
    params.feature
  )

  const requiredHeaders = {
    'Content-Type': 'application/vnd.contentful.management.v1+json',
    'X-Contentful-User-Agent': userAgentHeader
  }

  params = {
    ...defaultParameters,
    ...cloneDeep(params)
  }

  if (!params.accessToken) {
github contentful / contentful.js / lib / contentful.js View on Github external
throw new TypeError('Expected parameter space')
  }

  const defaultConfig = {
    resolveLinks: true,
    removeUnresolved: false,
    defaultHostname: 'cdn.contentful.com',
    environment: 'master'
  }

  const config = {
    ...defaultConfig,
    ...params
  }

  const userAgentHeader = getUserAgentHeader(`contentful.js/${__VERSION__}`,
    config.application,
    config.integration
  )
  config.headers = {
    ...config.headers,
    'Content-Type': 'application/vnd.contentful.delivery.v1+json',
    'X-Contentful-User-Agent': userAgentHeader
  }

  const http = createHttpClient(axios, config)

  const getGlobalOptions = createGlobalOptions({
    resolveLinks: config.resolveLinks,
    environment: config.environment,
    removeUnresolved: config.removeUnresolved,
    spaceBaseUrl: http.defaults.baseURL,

contentful-sdk-core

Core modules for the Contentful JS SDKs

MIT
Latest version published 1 month ago

Package Health Score

84 / 100
Full package analysis

Similar packages