halo-sdk-js v1.0.0-beta.2
This getting started guide will guide you on setting up HALO SDK for JavaScript in a few minutes. We will provide a step by step guide to get everything working with the most basic setup, for more detailed information please check the documentation:
https://mobgen.github.io/halo-documentation/docs/javascript/javascript_home
Getting started
Step 1: Add the HALO SDK
Install the Halo SDK npm dependency:
npm install --save halo-sdk-js
Step 2: Add HALO configuration
Import config from halo-sdk and apply the basic configuration based on your HALO project. Here you have the minimal configuration you will need.
import { config } from 'halo-sdk-js';
config.setup({
entrypoint: 'https://halo-db.com/',
credentials: {
clientId: 'YOUR_HALO_KEY', // you can obtain this value on the Halo CMS
clientSecret: 'YOUR_HALO_SECRET', // you can obtain this value on the Halo CMS
}
});
Step 3: Request a authToken
To start using the halo-sdk, you first need to receive a authToken.
import { auth } from 'halo-sdk';
const authToken = await auth.getToken();
Step 4: Obtain your HALO content
Use a search query to obtain the content you need, for example specifying the content module name and the item name.
import { content } from 'halo-sdk-js';
const query = new content.QueryBuilder()
.setModuleName('myModuleName')
.setSearchValuesQuery('name = Sample')
.build();
const searchResult = await content.search(query);
Step 5: Start using HALO in your app
Use any of the HALO APIs or plugins without worrying when is it ready, since this is managed internally by the different libraries.