Frontend call Service

Hello Team,

I replicate this project GitHub - cuba-platform/sample-session-planner: This is the project that is used in the Quick Start video for CUBA Platfrom framework. with React frontend module.
My goal is to call a Middleware Service from new (React) UI.
I followed this link CUBA Platform: TypeScript SDK and REST API - Java Code Geeks - 2023
I generated the entities from Intellij Cuba/Advanced/Managed Modules / Create Portal and also I used
npm install -g @cuba -platform/front-generator

And then

gen-cuba-front sdk:all
Seems that both made the same thing. Is there any difference between these two approaches?
On the other hand I expected to have in services.ts this code snippet:

export var restServices = {
   sessionplanner_SessionService: {
       rescheduleSession: (cubaApp: CubaApp, fetchOpts?: FetchOptions) => (params: sessionplanner_SessionService_rescheduleSession_params) => {
           return cubaApp.invokeService("sessionplanner_SessionService", "rescheduleSession", params, fetchOpts);
       }
   }
};

but I have only

import { CubaApp, FetchOptions } from "@cuba-platform/rest";

export var restServices = {};

What I did wrong?
What means
if we expose the Session Service using REST API? How can I do that?
Regards,
-n

Hi,

Please check the method of the service is exposed for REST API (i.e. is registered in rest-services.xml). See the documentation

I checked but doesn’t help me too much.
Regarding this example: GitHub - cuba-platform/frontend: Monorepo for CUBA Platform Frontend Tools and Libraries (Enums).

I put in services.ts this snipped

export enum CarType {
    SEDAN = "SEDAN",
    HATCHBACK = "HATCHBACK"
}

And I use a button to call the function into a Browser Screen:

<Button
      htmlType="button"
       onClick={this.functionRest}  
        >
        </Button>

and function

functionRest=()=>{
cubaREST.loadEnums()
.then(((enums: EnumInfo[]) => {
console.log(‘enums’, enums)
}));
}

In log I have:

GET
scheme http
host localhost:3000
filename /app/rest/v2/metadata/enums
Address 127.0.0.1:3000

Status

404

Not Found

VersionHTTP/1.1

Transferred460 B (165 B size)

Where is my mistake?

Regards,
-n

Hi,
Please check .env.development.local file. As React dev server typically runs on a different port (3000) we should specify full address to the rest API:

REACT_APP_CUBA_URL=http://localhost:8080/app/rest/