Embed Composer Components Using JavaScript and Trusted Access (Uncaught ReferenceError: getEmbedManagerPromise is not defined )
Hi all!
I am new on logi. I have problem with Embedding Visualisation Using JavaScript and Trusted Access.
Following steps from "Embed Composer Components Using JavaScript and Trusted Access" instruction console generated a issue during 4 step.
Issue:
Code:
-------------------------------------------------------------------------------------------------------------------------
<!DOCTYPE html>
<html>
<body>
<h1>Test</h1>
//Step 2
<script data-name="composer-embed-manager" src="'<samplecomposerurl>/embed/embed.js"></script>
<script>
//Step 3
window.initComposerEmbedManager({
getToken: getAccessToken
})
function getAccessToken() {
const client_id = 'abcabcabcabcabcabcabc',
client_secret = 'zxyzxyzxyz';
const authCode = window.btoa(`${client_id}:${client_secret}`);
return window.fetch(
'https://<samplecomposerurl>/composer/api/trusted-access/token',
{
method: 'POST',
headers: {
'content-type': 'application/vnd.composer.v2+json',
'Authorization': `Basic ${authCode}`,
},
body: JSON.stringify(
{ username: 'my username' }
),
credentials: "omit"
}).then(res=>res.json())
}
// Step 4 of instruction
//Sample
getEmbedManagerPromise.then((embedManager) => {
embedManager.createComponent('dashboard',
{
dashboardId: <id>, // dashboard id
<property>,... // set of properties
}
).then(dashboard => dashboard.render(
htmlElement, // htmlElement
{width: '100%', height: '100%'}
))
});
//My code
<script>
getEmbedManagerPromise.then((embedManager) => {
embedManager.createComponent('dashboard',
{
"type": "dashboard",
"dashboardId": "123123123123",
"interactivityProfileName": "interactive" // ? property copied from The embed snippet
}
).then(dashboard => dashboard.render(
htmlElement, // htmlElement
{width: '100%', height: '100%'}
))
});
</script>
</body>
</html>
0
-
great stuff
0
Please sign in to leave a comment.
Comments
1 comment