Creating a connection using the Mashup API

Now, while connecting to the engine is a fundamental step to start interacting with Qlik, it's very low-level, connecting via WebSockets. For advanced use cases, the Mashup API is one way to help you get up to speed with a more developer-friendly abstraction layer.

As already described in Chapter 10, Qlik Sense APIs Overview, the Mashup API utilizes the qlik interface as an external interface to Qlik Sense, used for mashups and for including Qlik Sense objects in external web pages.

To load the qlik module, you first need to ensure RequireJS is available in your main project file. You will then have to specify the URL of your Qlik Sense environment, as well as the prefix of the virtual proxy, if there is one:

<html>
<body>
<h1>Mastering QS</h1>
</body>
</html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.min.js">
<script>
//Prefix is used for when a virtual proxy is used with the browser.
var prefix = window.location.pathname.substr( 0, window.location.pathname.toLowerCase().lastIndexOf( "/extensions" ) + 1 );

//Config for retrieving the qlik.js module from the Qlik Sense Server
var config = {
host: window.location.hostname,
prefix: prefix,
port: window.location.port,
isSecure: window.location.protocol === "https:"
};


require.config({
baseUrl: (config.isSecure ? "https://" : "http://" ) + config.host + (config.port ? ":" + config.port : "" ) + config.prefix + "resources"
});

require(["js/qlik"], function (qlik) {
qlik.setOnError( function (error) {
console.log(error);
});
//Open an App
var app = qlik.openApp('MasteringQlikSense.qvf', config);
</script>

Once you have created the connection to an app, you can start leveraging the full API by conveniently creating HyperCubes, connecting to fields, passing selections, retrieving objects, and much more.

The Mashup API is intended for browser-based projects where authentication is handled in the same way as if you were going to open Qlik Sense. If you wish to use the Mashup API, or some parts of it, with a backend solution, you need to take care of authentication first.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.214.225