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