Content API Client
JavaScript SDK for Halo's Content API,implemented with TypeScript,encapsulating parameter types and return value types to make the use of API more brief.
Installation
npm install @nineya/halo-content-api --save
Usage
Here is a simple code for obtaining a list of posts.
import { ContentApiClient, HaloRestAPIClient } from '@nineya/halo-content-api'
// http request tool for halo rest api.
const haloRestApiClient = new HaloRestAPIClient({
baseUrl: process.env.HALO_BASE_URL,
auth: { apiToken: process.env.HALO_API_TOKEN },
})
// create contentApiClient by haloRestApiCLient.
const haloContentClient = new ContentApiClient(haloRestApiClient)
// obtaining a list of articles.
haloContentClient.post.list().then((res) => {
console.log(res)
})