System Information
- Strapi Version: 4.14.3
- Operating System: darwin-x64
- Database: mysql2
- Node Version: v18.16.1
- NPM Version: 9.8.0
I have 2 resources. (/api/resource1 and /api/resource2).
Both these resources are linked to a user. When each user wants to add values to these resources (from front end mobile App) 2 API calls are required (one for resource1 and second for resource2). These API calls are required itself in-case user wants to add only resource1 or resource2.
To avoid 2 separate API calls when user wants to add both, I created a new content-type resource3 that gives a basic bare minimum API endpoint that would intercept the request, extract resource1 and resource2 and then make further requests to resource1 and resource2 endpoints.
I am not able to get how to make the final requests to resource1 and resource2 endpoints. One way I am able to do is using axios/fetch to make new http calls to the endpoints. Is there any better way?
Some extra info -
- I tried using strapi.controller(uid : “api.resource1.resource1”).create(…). That works but it skips all the policy and middlewares setup for each resource. I can use same policies and middlewares for the new API endpoint created but both resource1 and resource2 some policy and middleware that is not being used for the other.
- I can create a single resource that adds both resource1 and resource2 in same table in DB but that is not what I want to do as both are totally separate entities and server different purpose.
- Based on the flowchart here - Back-end customization | Strapi Documentation, I sense some global middleware could be used but not able to find which can be used. Basically trying to do what Strapi actually does under the hood after a request is received on the server. I am not much aware of Strapi internals so not sure how easy is it achieve this (Is there a straigtforward way to achieve this?)