I created a smart relationship (hasMany) between two different collections. It’s working fine I can load the relationship data and it’s being shown in the Related Data section.
I’m facing one problem when I try to add a new item to the relationship created.
These are the steps:
- I click on the plus button
- I select that I want to add an existing relationship
- I search for the record I want to create the relationship
- I press the Add button
The result is that when I press the Add button the API call being sent to the Express Server is the same that is sent when the relationship data is loaded:
- it’s a GET request without any information about the relationship I want to create
For example this is the route that I defined to load the relationship data:
router.get('/templates/:template_id/relationships/categories' In my case the relationship is between templates and categories. I can load the data and is working fine.
When I click the button to add a new item to this relationship the same route above is triggered and I am confused why this is happening. Shouldn’t it be a POST request? Is this expected? If so how I am supposed to differentiate between listing records and creating relationships?