Anybody know if there is a guide or example for this anywhere please?
Let’s say for example I use a theme component to create a side column, how can I list the latest 20 publicly visible topics (or if it’s easier, from categories that I list in the query) in that side column/theme component?
There’s a couple of ways to do this. The simplest is to use an ajax call to the endpoint in the rails API that serves the data you want to display. If you want the latest 20 topics, then you might want to try /latest.json.
The challenge is if you need to combine info from multiple endpoints you then wait on multiple calls to complete which can really slow performance down in the theme component.
Do you think that that would be more or less the same as just hitting the DB with whatever queries those endpoints do anyway? (Or would it use significantly more resources since it could be the same as having to load 5 additional pages - one for each endpoint).
Either way I’d love to experiment with this - are there any guides or tutorials that show you how to fetch data from an endpoint into a theme component? (Or would it be better/more efficient to make a plugin instead?)
I know how to create a theme component and a ‘dummy’ plugin, but haven’t found any guides that show you how to fetch data from the DB into them.