toccojs v0.1.0
ToccoJS
ToccoJS is a JavaScript library for facilitating the interaction with the Tocco REST API.
Installation
You can use ToccoJS as a <script> tag from a CDN, or as a toccojs package on npm.
Examples
Checkout the examples directory in this repository.
Example of a simple Node script:
import tocco from 'toccojs'
tocco.initialize({
host: 'https://my.tocco.ch'
})
const entities = tocco.entities()
entities.list('User').then(data => {
console.log(data.length + ' Users received')
})API
initializeInitializes the app. This is required, before you can fetch or create any data.
Parameters:
config:host: Hostname as string (e.g. 'https://my.customer.ch')
setCredentialsSets the credentials to use for all subsequent requests.
Parameters:
credentials(object consisting ofusernameandpassword)
setBusinessUnitSets the business unit to use for all subsequent requests.
Parameters:
businessUnit(string)
entitiesReturns the entities API.
Entities API
listLists entities of the given model.
Parameters:
entityName
getFetches a single entity by key.
Parameters:
entityNamekeyoptionspaths: Which paths to include in the response
Develop
Install the dependencies: npm install
npm run build builds the library to dist, generating three files:
dist/toccojs.cjs.jsA CommonJS bundle, suitable for use in Node.js, thatrequires the external dependency. This corresponds to the"main"field in package.jsondist/htoccojs.esm.jsan ES module bundle, suitable for use in other people's libraries and applications, thatimports the external dependency. This corresponds to the"module"field in package.jsondist/toccojs.umd.jsa UMD build, suitable for use in any environment (including the browser, as a<script>tag), that includes the external dependency. This corresponds to the"browser"field in package.json
npm run dev builds the library, then keeps rebuilding it whenever the source files change using rollup-watch.
License
7 years ago