Getting JSON data for use in template

Hi,

I am trying to create a “Top Topics” box on the homepage of our mobile site. The box will contain three of the hottest topics on the forum.

To do this I am overriding the mobile/components/categories-with-featured-topics template. However, unlike on Desktop templates such as components/categories-and-latest-topics, I cannot seem to use a “topics” variable inside the handlebar template (I assume this is to do with what variables are passed to the different templates by another bit of discourse code).

So: I want to get some data using the Discourse api (such as top.json) and then use it in my handlebars template.

Does anyone have any great suggestions on how to do this?

Thanks very much, Max