11.4.0 • Published 5 years ago
zengenti-contensis-delivery v11.4.0
api-delivery-js
Contensis JavaScript Delivery API implementation written in TypeScript.
This allows the querying and retrieval of entries, content types and projects in JavaScript.
It can be used in any ES2015 compatible project.
- Angular
- React
- React Native
- NativeScript
Installation
The Contensis JavaScript Delivery API can be installed using npm.
npm install -save contensis/api-delivery-js
Examples
Using ES2015 async/await
import { Client } from 'api-delivery-js';
let contensisConfig = {
rootUrl: 'https://my-cms.com',
accessToken: 'MY_DELIVERY_API_ACCESS_TOKEN',
projectId: 'MY_PROJECT_ID',
language: 'en-GB',
versionStatus: 'published',
pageSize: 50
};
async function loadMovies() {
let client = Client.create(contensisConfig);
let movieList = await client.entries.list({
contentTypeId: 'movie',
pageOptions: { pageIndex: 0, pageSize: 10 },
orderBy: ['-releaseDate']
});
console.log(movieList.items);
}
loadMovies();
Using Promises
import { Client } from 'api-delivery-js';
let contensisConfig = {
rootUrl: 'https://my-cms.com',
accessToken: 'MY_DELIVERY_API_ACCESS_TOKEN',
projectId: 'MY_PROJECT_ID',
language: 'en-GB',
versionStatus: 'published',
pageSize: 50
};
function loadMovies() {
let client = Client.create(contensisConfig);
client.entries.list({
contentTypeId: 'movie',
pageOptions: { pageIndex: 0, pageSize: 10 },
orderBy: ['-releaseDate']
}).then(movieList => {
console.log(movieList.items);
});
}
loadMovies();
Documentation
Read our documentation on the Contensis Javascript Delivery API to learn of all it's features.
11.4.0
5 years ago