内容 Chef 管理 JS 客户端
安装
使用 npm :
$ npm install @contentchef/contentchef-management-js-client
使用线条 :
$ yarn add @contentchef/contentchef-management-js-client
实例
- 配置示例 此代码将显示如何正确配置您的内容化学管理 JS 客户端
class ContentChefApi {
api: ContentChefClient;
// The token is the authorizer that is needed to make actions in your space, for security problems the operation of setting the token
// should me make in a server side application
apiTokenResolver: AuthenticationTokenResolver = {
getToken: async () => {
return await 'do stuffs to retrieve your api token';
}
};
spaceIdResolver: SpaceIdResolver = {
getSpaceId: async () => {
return await 'do Stuff to retrieve your space id';
}
};
initializeClient = () => {
this.api = createChefSpaceClient(apiTokenResolver, spaceIdResolver, { apiRoot: 'https://mgmt.contentchef.io' });
}
}
// We do this to create a singleton of the client
export const contentChefApi = new ContentChefApi().initializeClient();
- 用法实例 此代码将显示在初始配置后如何正确使用您的内容Chef 管理 JS 客户端
class ContentChefContentStore {
api: ContentChefClient;
constructor (chefApi: ContentChefClient) {
this.api = chefApi
}
async getContent (reqParams: GetContentRequest) {
try {
const response = await this.api.contents.get(reqParam);
console.log('This is the requested content');
console.log(response);
} catch (e) {
console.log(`An error occurred retrieving the content with id ${reqParams.id}`);
console.log(e);
}
}
}
文档
生成新文档只需运行命令
使用线条 :
$ yarn generate-docs
将在项目根部的文件夹 Docs 内创建新文档, 然后在浏览器中只服务索引. html 文件