You can refer to the Cobalt’s GitHub repo for Javascript SDK here.
Install
First, install@cobaltio/cobalt-js
and via the terminal.
Browser
Initialise
ImportCobalt
and initialise it.
.getApp()
Returns the application details for the specified application, provided the application is enabled in Cobalt. If no application is specified, it returns all the enabled applications.Param | Required | Type | Description |
---|---|---|---|
[slug] | optional | String | The application slug |
Note: instance method ofCobalt
Returns:Promise.<Application>
- The application details.
.connect()
Returns the application details for the specified application, provided the application is enabled in Cobalt. If no application is specified, it returns all the enabled applications.Param | Required | Type | Description |
---|---|---|---|
[slug] | Mandatory | String | The application slug |
Payload | Optional | Object | The key value pairs of auth data |
Note: instance method ofCobalt
Returns:Promise.<Application>
- The application details.
.disconnect()
Disconnect the specified application and remove any associated data from Cobalt.Param | Required | Type | Description |
---|---|---|---|
[slug] | Mandatory | String | The application slug |
.config()
Returns the specified config, or creates one if it doesn’t exist.Param | Required | Type | Description |
---|---|---|---|
payload | Mandatory | configPayload | Json payload for config |
configPayload
object.
Name | Type | Description |
---|---|---|
slug | String | The application slug |
[config_id] | String | Unique id for the config |
labels | Object<string, Array<labels>> | The dynamic label mappings |
.updateConfig()
Update the specified config.Param | Required | Type | Description |
---|---|---|---|
payload | Mandatory | updateConfigPayload | Json payload for config |
updateConfigPayload
configuration data for an application.
Name | Required | Type | Description |
---|---|---|---|
slug | Mandatory | String | The application slug. |
[config_id] | Optional | String | Unique ID for the config. |
fields | Optional | Object | A map of application fields and their values. |
workflows | Optional | Array.<WorkflowPayload> | Whether the workflow is enabled. |
WorkflowPayload
data
Name | Required | Type | Description |
---|---|---|---|
id | Mandatory | String | The ID of the workflow. |
enabled] | Mandatory | Boolean | Whether the workflow is enabled |
fields | Mandatory | Object<string, (string or number or boolean)> | A map of workflow fields and their values. |
.deleteConfig()
Delete the specified config.Param | Required | Type | Description |
---|---|---|---|
slug | Mandatory | slug | The application slug. |
configId | optional | String | The unique ID of the config. |