@nuskin/cs-rest-api
v1.0.0
Published
Wraper around the Contentstack REST API to make using it in Javascript easier for Nu Skin.
Keywords
Readme
@nuskin/cs-rest-api
This library is used to perform functions using the Contentstack REST APIs. There are some cases where using the REST APIs are necessary inside Nu Skin (product data for example), so this library facilitates making those calls.
Functions that use the delivery token are under the delivery object, and functions using the management token are under the management object.
Installing
Usng npm:
npm add @nuskin/cs-rest-apiUsng yarn:
yarn add @nuskin/cs-rest-apiExample usage
const { csRestApi } = require('@nuskin/cs-rest-api')
const api = csRestApi({
apiKey: 'api_key',
managementToken: 'management_token',
deliveryToken: 'delivery_token'
})
const {management, delivery} = api
// Get latest published entry for Common English
let entry = await delivery.getEntry('product', 'uid')
// Get latest saved entry for US-en
entry = await management.getEntry('product', 'uid', 'US-en')
// Publish an entry
const res = await management.publishEntry(localizedKit.uid, ['en'], ['public-dev'])
