qlik-oss / enigma.js

JavaScript library for consuming Qlik's Associative Engine.
MIT License
210 stars 82 forks source link

Error: Global of undefined - QS Extension creating session app #56

Closed ClimberExtensions closed 7 years ago

ClimberExtensions commented 7 years ago

Description

I'm trying to create a session app with enigma.js in a Qlik Sense extension. But when I call getService('qix',enigmaConfig) I get this error: image And if I step in to the code, this is where it happens: image

Steps to Reproduce

enigma = '../.././external/qlik/enigma' qixSchema = 'text!../.././external/qlik/qix/3.2/schema.json' 'ng!$q' = $q 'qlik' = qlik app = qlik.currApp();

var enigmaConfig = { Promise: $q, appId: app.id, schema: qixSchema, session: { host: $window.location.host, secure: $window.location.protocol === 'https:' } }; enigma.getService('qix', enigmaConfig).then(function (qix) { console.log('qix', qix); });

Versions

marcusoffesson commented 7 years ago

Hi @ClimberExtensions!

It looks like qixSchema is invalid. I notice you load it as text while enigma expect it to be an object structure. Can you see if the config below works?

var enigmaConfig = {
    Promise: $q,
    appId: app.id,
    schema: JSON.parser(qixSchema),
    session: {
        host: $window.location.host,
        secure: $window.location.protocol === 'https:'
    }
};

On a side note, if you intend to create a session app, appId is not needed (and should not be part of the config).

kfsjostrand commented 7 years ago

Thanks for the quick response , that solved the problem!

peol commented 7 years ago

Awesome, thanks for responding :) Have a great weekend!