I am using tableau js api and calling worksheet.applyFilterAsync
& workbook.changeParameterValueAsync
methods based on certain conditions. These methods have an otherwise error handler.
I am also in between the executing flow return my custom promise like
return new Promise((resolve, reject) => {
resolve(true)
});
the issue is when i am returning promise and not changeParameterValueAsync
or worksheet.applyFilterAsync
i am getting an error
TypeError: undefined is not a function (near '...}).otherwise(function (err) {...')
looks like the promise i return does not have a otherwise error handler?
relevant code is as follows
const applyStep = (step) => {
if(step.step_type == 'filter') {
return worksheet.applyFilterAsync(step.name, values, 'replace');
} else if(step.step_type == 'parameter') {
return workbook.changeParameterValueAsync(`${step.name}`, value);
} else {
return new Promise((resolve, reject) => {
resolve(true)
});
}
};
const applyFilters = (counter) => {
return new Promise((resolve, reject) => {
let filter = filters[counter];
if(filter) {
applyStep(filter).then(promiseTimeout(filter.delay)).then(() => resolve(applyFilters(++counter))).otherwise(function(err) {
reject(err);
});
} else {
resolve(true);
}
});
};
I need the otherwise
error handler to handle error returned by tableau api methods but it does not work in cases where i am returning my custom promise, may be because the promise i am returning does not have an otherwise error handler?
How can address this any help in fixing this will be really great, Thanks.