It is a Development Kit that makes it easy to use Spearly CMS from JavaScript or NodeJS in API mode.
// npm
$ npm install -S @spearly/sdk-js
// yarn
$ yarn add @spearly/sdk-js
import { SpearlyApiClient } from '@spearly/sdk-js'
const apiClient = new SpearlyApiClient(SPEARLY_DOMAIN, API_KEY)
async function() {
// basic
const contents = await apiClient.getList(CONTENT_TYPE_ID)
// when using some options
const filteredContents = await apiClient.getList(CONTENT_TYPE_ID, { limit: 10, offset: 20 })
}
async function() {
const content = await apiClient.getContent(CONTENT_ID)
}
async function() {
const form = await apiClient.getFormLatest(FORM_ID)
}
async function() {
const submit = await apiClient.postFormAnswers(FORM_VERSION_ID, { ...YOUR_FORM_FIRLD_ANSWERS, _spearly_gotcha: '' })
}
Type definitions are also included, so there is no need to add anything else.
GetParams
: This is options that can be set when retrieving the ContentList.List
: The type of the content list returned by the API.Content
: The type of content returned by the API.Form
: The type of form returned by the API.