Getting and pushing data to the BCMS made easy. BCMS Client uses Api key to access data in your BCMS. You can use this library instead of making HTTP requests to your BCMS Instance.
Install the client (we are using GitHub packages so you will need to setup your project for them):
npm i --save @bcms/selfhosted-client
Initialize the client instance:
import { Client } from '@bcms/selfhosted-client';
const bcms = new Client(
'BCMS_ORIGIN', // ex. https://my-bcms-domain.com
{
// API Key is generated in BCMS Dashboard
id: 'API_KEY_ID',
secret: 'API_KEY_SECRET'
},
{
injectSvg: true, // If media is of type SVG, content fill be injected in the media object
enableSocket: true, // Receive updates from BCMS
useMemCache: true, // Cache BCMS responses
}
);
Have in mind that API Keys are scoped and you can set permissions in the BCMS Dashboard.
bcms.entry.getAllLite('<template_id_or_name>')