@thebcms/client
v1.5.7
Published
Make external communication with BCMS easy.
Readme
BCMS Client library
This library provides easy access to BCMS backend REST API.
Getting started
- Install package from NPM:
npm i --save @thebcms/client - Create a new Client instance and make a request to the BCMS:
import { Client } from '@thebcms/client/main';
async function main() {
/**
* Creating a new instance of the Client object
*/
const client = new Client(
'ORG_ID',
'PROJECT_ID',
{
id: 'KEY_ID',
secret: 'KEY_SECRET',
},
{
injectSvg: true,
},
);
/**
* Get all entries for template
*/
const entries = await client.entry.getAll('my-template-name');
console.log(entries);
}
main().catch((err) => {
console.error(err);
process.exit(1);
});Getting Entries
To get all Entries from BCMS for specified Template you can use:
const entries = await client.entries.getAll('my-template-name-or-id');Common question that we are get is how to query entries. Currently, we do not have native support for querying Entries, therefore you will need to filter Entries on client side, for example something like this:
const entries = (await client.entries.getAll('my-template-name-or-id')).filter(
(entry) => entry.meta.en.my_prop === 'some-value',
);