Hi
im trying to call external api from angular but getting an empty array when i run the fetchAndLock api here is my code
start(process) {
var payload = {
"variables":
{
"video": { "value": 'videoname1', "type": "String" },
}
}
this.http.post(`http://localhost:8080/engine-rest/process-definition/key/${process}/start`, payload)
.subscribe(res => {
console.log(res);
// this.processes = res;
//alert('Instance Created Successfully.');
//this.router.navigate(['start', process]);
this.submit('');
})
}
submit(value: any) {
console.log(value);
var payload = {
"workerId": "123456",
"maxTasks": 5,
"usePriority":true,
"topics": [
{
"topicName": 'get-user',
"lockDuration": 10000,
"variables": ["video", "winning", "winningDate"]
}
]
}
// this.http.get(`http://localhost:8080/engine-rest/external-task/`)
// .subscribe(res => {
// console.log(res);
// });
this.http.post(`http://localhost:8080/engine-rest/external-task/fetchAndLock`, payload)
.subscribe(res => {
console.log(res);
let result: any = [];
result = res;
for (var index = 0; index < result.length; ++index) {
var externalTask = result[index];
console.log(externalTask);
// addRowToTable('table' + topicName, JSON.stringify(externalTask));
this.http.post(`http://localhost:8080/engine-rest/external-task/${externalTask.id}/complete`, { "workerId": "123456" })
.subscribe((data) => {
console.log('data', data);
});
}
});
}
External topic name is “get-user”
and here is my nodejs code for external task
client.subscribe(‘get-user’, async function ({ task, taskService }) {
try {
// console.log('Varibales', Variables);
// const processVariables = new Variables();
// console.log(processVariables.getAllTyped());
const fullname = task.variables.get('fullname');
const email = task.variables.get('email');
const age = task.variables.get('age');
const video = task.variables.get('video');
// console.log('get user');
// console.log(task.variables);
// console.log(`saving to database`);
// console.log(`fullname: ${fullname}`);
// console.log(`Email: ${email}`);
// console.log(`fullname: ${age}`);
console.log(`Video: ${video}`);
// set a process variable 'winning'
// const processVariables = new Variables();
//processVariables.set("winning", 5);
// set a local variable 'winningDate'
// const localVariables = new Variables();
// localVariables.set("winningDate", new Date());
// console.log('winning', task.variables.get('winning'));
// console.log('winningDate', task.variables.get('winningDate'));
// console.log(taskService);
// console.log('task', task);
await taskService.complete(task);
console.log('done check-action1')
} catch (err) {
console.log(err);
}
});
Thanks in advance