Last Updated:
September 23, 2021
by
Muskan Purohit
| Version: 2
| 1,459 views
| 0 followers
members are following updates on this item.
Igloo developers will be able to leverage the IGLOO API set inside of any custom widget they build. This can be a point of confusion, as normally when a developer considers an IFRAME element, the first thing that comes to their mind is CORS and general cross-domain security restrictions. In the world of straight “blank canvas” front-end web development, IFRAMEs are not really used, and in fact the only true use case that is within specifications would be using an IFRAME to display separate content on the same domain. This is how the Integrations Widget works. Since it’s the same domain as your IGLOO community, and the page is rendered by the platform, there are no real CORS issues. A developer will need to just make slight adjustments to their best practices and normal approach in this area.
There are no architectural limitations or any alteration to how one would expect an HTTP request to be handled by the run-time environment of a web browser in this scenario. However, because the custom software is operating within a clean, dedicated Document-Object-Model (the IFRAME,) no JavaScript or anything running on the IGLOO page itself is directly accessible by the widget. That means things like the “Igloo” JavaScript object, or the mooTools JavaScript API client. That client is legacy and should no longer be used anyways. The next section on Usage describes how to workaround this properly.
Tip: If compatbility with off-version web browsers is important to your organization, you will need to use XmlHttpRequest directly, or find a JavaScript library that provides a poly-fill or shim for Fetch.
The following illustrates how to make a basic API call to the IGLOO digital workplace, from within an Integrations widget:
xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
data = JSON.parse(xhr.responseText);
console.log(data);
}
}
xhr.open("GET", "/.api/api.svc/community/members", true);
xhr.setRequestHeader("Accept", "application/json");
xhr.send();
(Fig. 3.1) XmlHttpRequest makes a GET request to display all members of the digital workplace