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

contensis-management-api

Package Overview
Dependencies
Maintainers
5
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

contensis-management-api

Contensis Javascript Management API

  • 1.0.2-beta.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
989
decreased by-2.37%
Maintainers
5
Weekly downloads
 
Created
Source

contensis-management-api NPM version

Contensis JavaScript Management API implementation written in TypeScript. This version targets Contensis 14.0 and above.

The contensis-management-api-examples repo contains Express and React examples.

Installing and importing the client npm package

The Contensis JS Management API client is delivered as an npm package, with publicly available source code and examples.
The client package can be used in a modern browser, in Node.js or as cross-platform client (e.g. a React.js application, a Node.js console application, an Express.js web application, a JavaScript or TypeScript library).

Note

Before following the rest of the examples we assume you have an existing Node.js or Express.js application that is already created, that targets Node.js >= 10 and uses the CommonJS module system (you can also use native JavaScript modules - see examples).
The Contensis JS Management API client is using the fetch API to maintain consistency with the Contensis JS Delivery API client. The fetch API is not a native Node.js API and it is loaded from the node-fetch npm package when the Contensis JS Management API client runs in a Node.js environment (if it runs in a browser enviroment the native fetch API will be used instead).

To install the required packages for the Contensis JS Management API client please run the following Node.js command:

npm install contensis-management-api

Import default Client if you are using CommonJS modules:

const Client = require('contensis-management-api').Client;

Import the default Client if you are using native JavaScript modules:

import { Client } from 'contensis-management-api';

The default Client class exported in the contensis-management-api package targets primarily a modern browser and assumes the fetch API is already made available.

As an alternative you can use the UniversalClient class that ensures fetch API is always made available regardless if you are in a browser context or a Node.js context.

Import UniversalClient if you are using CommonJS modules:

const UniversalClient = require('contensis-management-api/lib/client').UniversalClient;

Import UniversalClient if you are using native JavaScript modules:

import { UniversalClient } from 'contensis-management-api/lib/client';

Some Contensis JS Management API functionality is only available in a Node.js environment (e.g. creating and updating assets). In this scenario you need to use the NodejsClient class ensures fetch API is made available.

Import NodejsClient if you are using CommonJS modules:

const NodejsClient = require('contensis-management-api/lib/client').NodejsClient;

Import NodejsClient if you are using native JavaScript modules:

import { NodejsClient } from 'contensis-management-api/lib/client';

Creating and using the client instance

All operations for the API hang off the Client type (or UniversalClient and NodejsClient if you are using those), which is created using the static method call Client.create(options). The options object represents the shared configuration that will be used by all Management API calls and is of type Config:

const client = Client.create({
  clientType: "client_credentials",
  clientDetails: {
    clientId: '6f8cf1e8-b2ee-49ad-9b94-2dbb09871903',
    clientSecret: '6d80c9a356ce4317bd71d92c5734d67a-4a837b1336344f63b1b24ce2dfa73945-ef09daa8d0f74b1e8e223779c392a67b'
  }
  projectId: 'website',
  rootUrl: 'https://cms-example.cloud.contensis.com'
});

client.contentTypes.list()
  .then(result => {      
      console.log('API call result: ', result);        
      return result;      
  })
  .catch(error => {
    console.log('API call fetch error: ', error);      
    throw error;
  });

Keywords

FAQs

Package last updated on 30 Nov 2020

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