How to access community data inside a custom widget
This article shows developers how they may access Igloo community data from inside a custom widget.
Note: Custom widgets are rendered on the page inside an iframe, thus functions of the parent document/window are not directly accessible by the logic inside your widget.
Tip: Since the iframe that contains the widget is rendered directly on the page from the same domain, there are no CORs issues and this document outlines how to modify your code to access the parent document/window.
How to retrieve community data
Use the following code to access community data inside your custom widget (Fig. 2.1):
(Fig. 2.1) Access community data within a custom widget.
The above script will output the following data for developers to work with (Fig 3.1):
(Fig. 3.1) Console output of community data.
To learn more about how an iframe can interact with the parent document, and vice-versa, check out this MDN article