[Widget]Realtime topic updates


  • Gamers

    I need to know if there is an client side ajax method that i can use to poll for latest topics from selected categories. if there isn't, please suggest an alternative approach.


  • Community Rep

    You can get the data from any route by adding /api to the front of the route.

    $.getJSON('/api/category/1', function (data) {
        console.log(data.topics);
    });
    

    Will return up to the 20 most recent topics. The same that the user would see if they were viewing the page for category 1.


  • Gamers

    @yariplus said:

    $.getJSON('/api/category/1', function (data) {
    console.log(data.topics);
    });

    I think i got this as a response for the request: "/category/1/announcements"

    Don't know if i am doing it wrong. I created a new html widget and added your script inside a script tag. In the console, I am not getting anything. But i can see the request is successful, but there is no console.log outputting. In the network tab, i can see the response for this request as : "/category/1/announcements"

    Sorry for the bad english


  • Gamers

    Anyway, I get all the categories and topics using this route: /api/categories

    I think there is details on all topics also.


Log in to reply
 


Looks like your connection to NodeBB was lost, please wait while we try to reconnect.