How to use the contentful-sdk-core.createHttpClient 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.js / lib / contentful.js View on Github external
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,
    environmentBaseUrl: `${http.defaults.baseURL}environments/${config.environment}`
  })
  // Append environment to baseURL
  http.defaults.baseURL = getGlobalOptions().environmentBaseUrl

  // Intercepts response and obscure the token
  obscureAuthTokenInResponse(http)

  return createContentfulApi({
    http,
github contentful / contentful-management.js / lib / contentful-management.js View on Github external
params = {
    ...defaultParameters,
    ...cloneDeep(params)
  }

  if (!params.accessToken) {
    throw new TypeError('Expected parameter accessToken')
  }

  params.headers = {
    ...params.headers,
    ...requiredHeaders
  }

  const http = createHttpClient(axios, params)
  const api = createContentfulApi({
    http: http
  })

  return api
}

contentful-sdk-core

Core modules for the Contentful JS SDKs

MIT
Latest version published 23 days ago

Package Health Score

86 / 100
Full package analysis

Similar packages