on 2024 Nov 14 4:07 PM
Hello SAP Experts,
I am currently trying to run parallel httpRequests in my CAP Project via Promise.all().
When I start my service in BAS and run the function for the first time, with at least two calls, I get the error message: “Failed to load destination”. When I run it again, it runs without errors.
Also when I start my service in BAS and run the function for the first time, with one call, there is no error message.
This is my Promise.all() call.
for (const oObj of aObjects) {
aViewRequests.push((async () => await extAPI_content.readView(sEnvironment, sSpace, oObj.technicalName))());
// Inside of this function the Method _callDatasphereAPI is called which is listed down bellow.
}
const oSpaceObjectsDetails = await Promise.all(aViewRequests);
...
// here the implementation of the executeHttpRequest
async function _callDatasphereAPI(oRequestOptions, bMinimizeLogs) {
let oResponse = null;
try {
if (!bMinimizeLogs) {
LOG._debug && LOG.debug(`${FILEIDENT}|Call DS Wrapper - Query Parameters: ${JSON.stringify(oRequestOptions)}`);
} else {
LOG._debug &&
LOG.debug(
`${FILEIDENT}|Call DS Wrapper - Environment: ${oRequestOptions?.data?.environment}, Method: ${oRequestOptions?.method}, URL: ${oRequestOptions?.url}`
);
}
if (!oRequestOptions.method || !oRequestOptions.url) {
throw "Http request have missing properties.";
}
oRequestOptions["middleware"] = [timeout(120000)];
oResponse = await executeHttpRequest(
{
destinationName: "datasphere-wrapper-api"
},
oRequestOptions
);
} catch (error) {
if (error?.response) {
oResponse = error.response;
} else {
oResponse = {
status: -1,
message: !error.message ? error : error.message
};
}
}
return oResponse;
}This error only occurs when I run the app locally in BAS. If I deploy the app, this error does not occur.
INFO: Locally I bound the destination service instance from the BTP to execute the calls.
This is the exact error message:
ErrorWithCause: Failed to load destination.
Caused by:
ErrorWithCause: Could not fetch client credentials token for service of type "destination".
Caused by:
Error: Could not fetch client credentials token for service of type destination: HTTP request [XsuaaService.fetchClientCredentialsToken] to https://<Link>/oauth/token could not be sent due to: FetchError: request to https://<Link>/oauth/token timed out..
Maybe anyone also tried the Promise.all with async/await calls.
If yes, please help me out.
Thanks,
Jonas
Request clarification before answering.
You need a destination service instance binding to fetch the destination data from the BTP cockpit.
please check if you have the destination service and xsuaa service instance binding.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 18 | |
| 7 | |
| 6 | |
| 6 | |
| 6 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.