Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
contentful-sdk-core
Advanced tools
The contentful-sdk-core npm package provides core functionalities for interacting with the Contentful Content Delivery API. It is designed to be a foundational library that other Contentful SDKs can build upon, offering utilities for making HTTP requests, handling responses, and managing errors.
HTTP Client
This feature allows you to create an HTTP client configured to interact with the Contentful API. The code sample demonstrates how to create an HTTP client using Axios and make a GET request to fetch entries.
const { createHttpClient } = require('contentful-sdk-core');
const axios = require('axios');
const httpClient = createHttpClient(axios, {
accessToken: 'your_access_token',
space: 'your_space_id'
});
httpClient.get('/entries')
.then(response => console.log(response.data))
.catch(error => console.error(error));
Error Handling
This feature provides a standardized way to handle errors that occur during API requests. The code sample shows how to use the errorHandler function to manage errors from a GET request.
const { createHttpClient, errorHandler } = require('contentful-sdk-core');
const axios = require('axios');
const httpClient = createHttpClient(axios, {
accessToken: 'your_access_token',
space: 'your_space_id'
});
httpClient.get('/entries')
.then(response => console.log(response.data))
.catch(error => errorHandler(error));
Request Configuration
This feature allows you to configure various aspects of the HTTP requests, such as headers and query parameters. The code sample demonstrates how to add custom headers to the HTTP client.
const { createHttpClient } = require('contentful-sdk-core');
const axios = require('axios');
const httpClient = createHttpClient(axios, {
accessToken: 'your_access_token',
space: 'your_space_id',
headers: {
'X-Custom-Header': 'customValue'
}
});
httpClient.get('/entries')
.then(response => console.log(response.data))
.catch(error => console.error(error));
The 'contentful' package is a higher-level SDK that builds on top of contentful-sdk-core. It provides more abstracted and user-friendly methods for interacting with the Contentful API, such as fetching entries, assets, and content types. It is more feature-rich and easier to use for common tasks compared to contentful-sdk-core.
The 'contentful-management' package is another higher-level SDK that focuses on the Contentful Management API. It allows you to manage content types, entries, assets, and more. Like the 'contentful' package, it builds on top of contentful-sdk-core but is tailored for content management tasks rather than content delivery.
While 'axios' is a general-purpose HTTP client and not specific to Contentful, it is often used in conjunction with contentful-sdk-core to make HTTP requests. It provides a flexible and powerful API for making HTTP requests, handling responses, and managing errors, similar to the core functionalities provided by contentful-sdk-core.
This package contains some core modules and utilities used by both the contentful.js and contentful-management.js SDKs.
Contentful is a content management platform for web applications, mobile apps and connected devices. It allows you to create, edit & manage content in the cloud and publish it anywhere via a powerful API. Contentful offers tools for managing editorial teams and enabling cooperation between organizations.
npm install --saveDev contentful-sdk-core
This package contains some core modules and utilities used by both the contentful.js and contentful-management.js SDKs.
We support all current browsers in their last 3 versions including IE 11. The minimal node version is 4.
For bundlers like webpack2 and rollup we support the module
&
jsnext:main
entry in the package.json
npm run build
Run only the unit tests:
npm run test:only
Run unit tests including coverage report:
npm run test:cover
Run unit tests with coverage report and display the result in your browser:
npm run browser-coverage
Emulate a CI test run:
npm run test:ci
Enable debug mode for tests:
npm run test:debug
FAQs
Core modules for the Contentful JS SDKs
We found that contentful-sdk-core demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.