Hi,
I am struggling with calling the cds.spawn function properly
https://cap.cloud.sap/docs/node.js/cds-context-tx#cds-spawn
We are running requests to remote endpoints inside the spawned transaction which propagates the user (via SAML Bearer Assertions). So the spawned transaction needs access to the JWT token of the incoming request as far as I can understand.
What is the appropriate way to call cds.spawn to achieve this. We are trying
this.on('myAction', 'MyEntity', async (req, next) => { const continuationFunction = () => {/* ... */} cds.spawn(req, continuationFunction); // Throws Error: The passed options must not be an instance of cds.EventContext. cds.spawn(cds.context, continuationFunction); // Throws Error: The passed options must not be an instance of cds.EventContext. cds.spawn({user: cds.context.user}, continuationFunction); // Runs, but fails to fetch destinations for remote service calls later (no JWT Token)) }
What is the right way here? Thanks in advance!
//Carl