Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For more info regarding the Camunda API see: https://docs.camunda.org/manual/7.3/api-references/rest/

More information regarding Kinvey Flex Services here: Kinvey Flex Services
Example:

Code Block
languagejs
titleCamunda Service Example
linenumberstrue
const sdk = require('kinvey-flex-sdk');

...


const DigestFetch = require('digest-fetch');

...




Class CamundaService

...

 {

?? ?? ?? ?? constructor(){
?? ?? ?? ?? ?? ?? this.client = new DigestFetch(userName, password);

...


?? ?? ?? ?? ?? ?? this.logger = flex.logger;

...



}


getAll (context, complete, modules)

...

 {
?? ?? this.logger.info('getAll Context:' + JSON.stringify(context));

...


?? ?? const backendUrl = "url to camunda backend";
?? ?? this.client.fetch(backendUrl)

...


?? ?? ?? ?? .then(response => response.json())

...


?? ?? ?? ?? .then(data =>

...

 {
?? ?? ?? ?? data.forEach(item =>

...

 {
?? ?? ?? ?? ?? ?? item._id = item.id;

...


?? ?? ?? ?? });
?? ?? ?? ?? complete().setBody(data).ok().next();

...


?? ?? })
?? ?? .catch(e => console.error(e));

...


}

...



}

...



sdk.service((err, flex) =>

...

 {
?? ?? ?? ?? const data = flex.data;?? ?? ?? ?? ?? ?? ?? ??//get data object
?? ?? ?? ?? const flexLogger = flex.logger;??//get logger

?? ?? ?? ????const camundaFlexServive = data.serviceObject('task');

...

??//get service object from data

...

 object
?? ?? ?? ????camundaService = new CamundaService(key, flex);

...

?? ?? ?? ??//instantiate new service

...

 class
?? ?? ?? ?? camundaFlexServive.onGetAll(camundaService.getAll.bind(camundaService)); //bind handler function to getAll event

...



}