Thank you very much for the support. This helped me to figure out how to send a request from the frontend to the backend, without specifying the CSRF-token but rather using the splunk_js_sdk to do that for me. I ended up with following function, to add to my api.js file. const postFetchData = async ( endpoint, data ) => {
// splunk_js_sdk can be imported from "splunkjs/splunk" within 'define()'
const http = new splunk_js_sdk.SplunkWebHttp();
const service = new splunk_js_sdk.Service( http, appName );
const result = await service.request(
`/services/${endpoint}`,
'POST',
{}, {},
JSON.stringify( data ),
{'Content-Type': 'application/json; charset=UTF-8'},
( res, err ) => {
return ( !err ) ? res : err
}
)
return result
}
// make sure to be in an async context when calling 'await'
const response = await postFetchData( '<your-endpoint>', your_data )
// Following line will most likely output a STRING!
// try turning it into json inside try-catch-block.
console.log( response ) May be someone out there will appreciate the Copy-Pasta.
... View more