Get topic content - Fluid Topics - Latest

Fluid Topics Designer Guide

Category
Reference Guides
Audience
public
Version
Latest

The getContent() JavaScript method returns the HTML content of the currently open topic. It is only available in the Topic template designer.

It corresponds to the Get the content of an HTML section web service.

Example

The following example prints the HTML content of the currently open topic in the user's browser console.

async function getTopicContent() {
    try {
        const content = await topic.getContent();
        console.log(content);
    } catch (error) {
        console.error("Error fetching topic content:", error);
    }
}

// Call the function to get the topic's HTML content
getTopicContent();

Response

The following example is the output of topic.getContent() for the Postman collection topic of the Fluid Topics API Reference Guide:

<div class="ft_node_extractor content-locale-en-US content-locale-en">
<p>The Fluid Topics web services are available as a Postman collection. It offers pre-filled requests to let users quickly test and interact with the Fluid Topics web services using Postman.</p>
<p>Select the following button to view the collection, to fork it, or to import a copy.</p>
<div class="postman_button">
    <a href="https://god.gw.postman.com/run-collection/16206991-0f67dfa9-72ad-4d42-ac71-5fd480b6b1fc?action=collection%2Ffork&amp;source=rip_markdown&amp;collection-url=entityId%3D16206991-0f67dfa9-72ad-4d42-ac71-5fd480b6b1fc%26entityType%3Dcollection%26workspaceId%3D65b2cb8b-dc25-48ac-98c7-c73e95c09e0b" rel="noopener" class="ft-external-link">
        <img src="https://run.pstmn.io/button.svg" alt="Run in Postman">
    </a>
</div>

<p>It is also possible to select the orange arrows next to the titles of topics, which lead to the request in the Postman collection.</p></div>