@content-island/api-client
v0.16.0
Published
Content Island - REST API Client
Downloads
519
Readme
@content-island/api-client
Installation
npm install @content-island/api-clientExamples
Basic Usage
// Your model
interface Post {
id: string;
title: string;
body: string;
order: number;
language: 'es' | 'en';
}import { createClient } from '@content-island/api-client';
const client = createClient({ accessToken: <your-token>});
const postsWithDefaultLanguage = client.getContentList<Post>({ contentType: 'post'}); // Retrieve the list of contents in the project filtered by content type, for example 'post' in the
const englishPosts = client.getContentList<Post>({ contentType: 'post', language: 'en'}); // Get english posts
const spanishPosts = client.getContentList<Post>({ contentType: 'post', language: 'es'}); // Get spanish posts
// Or you can retrieve a content by id
const postById = client.getContent<Post>({ id: 'content-id', language: 'es' }); // Retrieve a content by id
const postBySomeField = client.getContent<Post>({ 'fields.title': 'post-title', language: 'es' }); // Retrieve a content by field value
Documentation
For more detailed documentation, please refer to the Content Island API Client documentation.
