Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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,
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
}