Display a value from an external webservice in the header

Kia ora folks,
Just a need a (hopefully) quick pointer in the right direction. I want to retrieve a value (json) from an external URL and display it in the header.
The webservice is public and just returns a single value like this:

{
    "CounterValue": 25
}

I’m running discourse self-hosted, standard install.
I’m not too concerned if the call is made client side or server side, the webservice is public.
What’s the best way to approach this. Would I need a plug-in, a theme component? Or can this be done out of the box?

Cheers
Rhys

A theme component is easier to install and maintain. It would make the remote ajax call at least for every user (if it doesn’t change, though, I think one call in an intitializer wouldnt’ be that big a deal).

A plugin might allow you to cache the result and just add it to the serializer.

3 Likes

This does nearly everything you’d want. Just fork it, substitute the web service and tailor the presentation to suit your needs:

3 Likes

Brilliant, thank you both. That’s got me underway.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.