I’m a bit new and I’m still looking for some optimization in my code to have the best performance but, I’m crossing some problem of comprehension…
At first I pimped my editor. I’m currently using the tinyCME (quite enough easy to custom), So my use case is the following:
After create my preview to check the post before submit it, I make a function which parse the editor return (HTML) to change links and attributs (few details). But in the function that’s happen to have post’s id, and I should go to the post from the bdd to build the URL. Nothing to hard to do but I wanted to found my post obj with the following command :
Not from the admin panel, you have to run via rest as the admin panel is CSR React so it’s ran by the clients browser.
And the admin has it’s own REST controllers, if you go to the admin panel and open your dev-tools in the browser (network tab) you can see the requests being made. For example I have a model called test and the get request for a findOne looks like:
So if I understand how the admin panel is CSR React so we can’t call the REST controllers defined in the api folder (location strapi/api/whateverController/*.js). So expect the way I mention in the init question I can’t do more ‘better’ ?
I mean my purpose is to make something clean as you did for the admin panel editor (location extension folder where I custom my editor). So there is solutions that strapi already provide to call the REST controllers, instead of the https requests use to do when front talk with a server ? because I would like to shut all my api public routes.
I’m not sure if I’m enough clear… but step by step is the following:
Create / Edit post on the admin panel ;
Typing some text inside the post’s body (rich text) ;
Press bellow the editor ‘Preview’ button (just display the HTML from the editor in a modal) ;
During the step 3, before render the HTML. I need to fetch from the BDD, posts mentioned. So I parse my HTML to find post’s ids and get then from bdd to have the most accurate preview.
It’s the moment where I need to access the REST api to get the data more efficiency (quickly, etc…) instead of making http request to do what I mentioned earlier and shut all my public route.