cancel
Showing results for 
Search instead for 
Did you mean: 

CAP does not implement my service

NicolasSchwarz
Explorer
0 Kudos

I created a services.js and services.cds with following content. There are no errors but de cds watch shows me that services.js is not implemented like in the tutorials and I am actually not sure about the problem...

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate

Are you sure you cds and js file names match exactly. I see in your one screen shot that the Services.js has a capital S. Does your cds file also use a capital S? Even case matters when matching here. If that's not the situation, then please post a screenshot of your project structure. Also consider that you can configure the handler explicitly in the service cds file if you don't want the automatic name mapping.

NicolasSchwarz
Explorer
0 Kudos

Hey, yes they have exactly the same name. In relation to your other point, is it possible to write it in the same file with handler in js? Or is it then also in the "cds language"?

thomas_jung
Developer Advocate
Developer Advocate

No you can't write you exit handler in the cds file itself. But you can explicitly tell CAP where to find the handler. Example here: https://github.com/SAP-samples/hana-opensap-cloud-2020/blob/main/srv/service.cds#L23

NicolasSchwarz
Explorer
0 Kudos

So, I tried this, no error, but still no implementation. I have no idea what it could be...

Answers (2)

Answers (2)

leoirudayam
Advisor
Advisor
0 Kudos

What exactly does not work? I see you use latest @sap/cds 4 notation, do you have the right version also included in your package.json?

You read handler is appearing first of all "after" and not attached to any entity? What is your expected outcome or where do you want your json payload to be returned?

NicolasSchwarz
Explorer
0 Kudos

So I changed it to this.on again, first of all I just want to give me a test json back, later on I want to use the entities for User. When I call the [...]/login via fetch request I just want to get my test json first of all.

NicolasSchwarz
Explorer
0 Kudos

Note: the change to this.on doesn't have any effect

leoirudayam
Advisor
Advisor
0 Kudos

I don’t understand what’s your objective for overriding your OData Entry Point for your service, where metadata is handled and all Entities, Entity Sets, Functions etc. are defined. Furthermore, you need to be aware if you want to override the read handler, to return the same structure like your cds Service has defined

NicolasSchwarz
Explorer
0 Kudos

Here are the screenshots, not sure why it didn't work the first time