I am trying to condense a potentially large switch case into a simple expression in nodejs. This is what I current have
exports.ManagerRequest = functions.https.onCall(async (data, context) => {
console.log('[INDEX], @request1',data);
const func = data.function
const data1 = data.value
switch (func) {
case 'request1':
const res = manager.request1(data1)
break;
case 'request2':
const res = manager.request2(data1)
default:
console.log(`Sorry, we are out of ${func}.`);
}
return res
})
I have manager imported and many functions in manager which i am calling based on the requested function in data. The switch cases will significantly expand. is there a way to call automatically insert the function name and associated data. something that look like this
const res = manager.'{func(data)}'
How can the function name and data be dynamically generated ?