Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Use destination instead of environment variables for Cloud Foundry API credentials #7

Open
gregorwolf opened this issue Jul 5, 2021 · 1 comment

Comments

@gregorwolf
Copy link
Contributor

HI @andrewlunde,

ask you know I never liked the way how the the credentials for the Cloud Foundry API where provided in this example. I've found now the better solution: Create a destination in the SAP BTP Subaccount with the following configuration:

Screenshot 2021-07-05 at 08 53 52

The destination details can then be read using the getDestination method from @sap-cloud-sdk/core. Then you can either use cf-http-client (which does not yet support all API Endpoints). Or stick with the axios calls.

CU
Gregor

@piejanssens
Copy link

I belief nowadays you can even use @sap/cds itself for REST on a remote service (BTP destination). Either way, destinations are the way to go.

let oPayload = ...
const btpApi = await cds.connect.to("CloudFOundryAPI")
const res = btpApi.tx(req).post("/v3/routes", oPayload)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants