How to call API from client side.
-
So, im trying to add the "follow/not follow" feature to the categories template. I want users to be able to use this feature from the topic list item, instead of going to the topic detail page, and then there use the feature.
So, I've added the "follow/not follow" component to each item in the list, and now trying to set the javascript functionallity from client side.
I've seen how this is set in the core, in the public/src/client/topic/threadTools.js . But there I see a call to
api[method](`/topics/${tid}/${type}`, {}, () => {
and to
translator.translate(titles[state], function (translatedTitle) {
that I can't do as I don't know how to get that api and translator variables set on my client side.
any tips? or Am I doing it wrong?
-
require(['api', 'translator'], (api, translator) => { // Your code here });
-
@PitaJ said in How to call API from client side.:
require(['api', 'translator'], (api, translator) => {
// Your code here
});genius! and fast reply!