on 2023 Sep 29 10:52 AM
As we all know that to call remote odata service, We need to use cds import for edmx or we can use axios or different npm module to achieve same. Is there anyway to use cds.connect without edmx import.
Thanks
Hi Somnath,
I've tried the following way for a plain (non-OData) Rest API.
package.json file:
´´´"dependencies": { "@sap-cloud-sdk/http-client": "^3.1.1",... } ´´´
"cds": { "requires": { "restApi": { "kind": "rest", "credentials": { "destination": "rest-api-destination" } } } ´´´
in custom handler
const restApi = await connect.to("rest-api-destination");
const { Workspace, Region } = this.entities;
this.on("READ", Workspace, async (req) => {
try {
return await restApi.get(`/Workspace/${req.data.workspaceId}`);
} catch (err) {
if (err.statusCode && err.reason.message) {
req.reject(err.statusCode, err.reason.message);
}
}
});
Note: just used with Non-OData API, I have no idea whether it works or not with OData API.
Kind regards,
Bruno Franzini
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
69 | |
11 | |
10 | |
10 | |
9 | |
9 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.