Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

contentful-sdk-core

Package Overview
Dependencies
Maintainers
5
Versions
131
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contentful-sdk-core

Core modules for the Contentful JS SDKs

  • 6.3.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
777K
decreased by-37.08%
Maintainers
5
Weekly downloads
 
Created

What is contentful-sdk-core?

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.

What are contentful-sdk-core's main functionalities?

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));

Other packages similar to contentful-sdk-core

FAQs

Package last updated on 11 Jun 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc