Skip to content
Advertisement

JHipster React Show List Of One Entity in Details Screen of Another Related Entity

I am attempting an application in JHipster 7.0.1 (Azul JDK 11) and ReactJS as the front-end.

I have 2 entities in my JDL – Domain and BadgeCategory that are related as shown below

JavaScript

I want to be able to display all the BadgeCategories for a particular Domain in the Domain Detail screen.

For this, I created a new method in the repository BadgeCategoryRepository.java

JavaScript

And then added a new endpoint in BadgeCategoryResource.java

JavaScript

Now coming to the React part, I added a constant in badge-category.reducer.ts

JavaScript

Then I am using this reducer in the Domain Detail screen component domain-detail.tsx

JavaScript

I am expecting the constant badgeCategoryList to contain the list of all badge categories for the domain which is being referred to in the domain-detail screen. But I get nothing in return.

On checking the flow, I see that the endpoint is getting hit and the response is being produced by the Java code, but the UI code is not able to consume it.

What am I missing here that is causing this issue?

ConsoleLogs

The Swagger docs show expected response from the Java code

Swagger

Advertisement

Answer

So the issue was with the new API call not being registered with the slice section in the reducer. I had to do the following addition to the slice and it works like a charm

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement