Qlik Community

Integration, Extension & APIs

Discussion board where members can learn more about Integration, Extensions and API’s for Qlik Sense.

Announcements
Support Case Portal has moved to Qlik Community! Read the FAQs to start exploring Support resources.
cancel
Showing results for 
Search instead for 
Did you mean: 
zadravecm
Contributor III
Contributor III

npm node library in Qlik sense visual extension

Hi,

I would like to include Request library in my extension.

I know that Qlik Sense use RequireJS for bringing resources in extension.

So I did something like this:

define([

        "jquery",

        "request"

    ],

    function(jq, request) {

......

     });

But I get (in browser - developer tools) error :

Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:4848/resources/request.js?.....

I did do:

npm install request

inside my_extension folder.

What I am doing wrong?

5 Replies
ErikWetterberg

Hi,

If you load additional libraries in your extensions you need to use a relative path. So if you want to load library xxxx.js you put it in folder xxxx under your main extension folder and then load it with:

define(['./xxxx/xxxx'],function(xxxx){ //note the dot!!

........

}

Assuming that the library can be loaded with requirejs.

Hope this helps

Erik Wetterberg

zadravecm
Contributor III
Contributor III
Author

Thank you for reply. I see that you could specify the external js file with relative path.

My problem however is that I would like to include whole model (a lot of js files) to this extension.

The problem is, that I could include main js file (in my case request.js) , but all other dependencies inside this modul (request.js file) will not be resolved.

I also have a problem, that if I try to do:

define([

        "jquery",

        "./node_modules/request"

    ],

    function(jq, request) {

......

               var req = { method: 'GET', url: '/hello', baseUrl: baseUrl };

                request(req, this.log);

....

});

it seas :

request is not a function. (Witch I understand, that define function return object. But I need to call init function in this case).

Do you have any experience with this?

ErikWetterberg

Hi,

This looks like somthing meant for nodejs rather than the browser. Why do you need it? Generally you should avoid loading a lot of files in an extension, if possible use a packaged solution.

Erik Wetterberg

zadravecm
Contributor III
Contributor III
Author

Isn't RequireJS from NodeJS?


I can see that in the beginning the whole library jquery is loaded. I would like to do it similarly with other library.

I have for example CryptoJS, witch I can't found to be as a single JS file.


ajaykakkar93
Specialist
Specialist

Hi erik.wetterberg,

     i am trying to load mysql in to my extension itselfe so do you have a way to do that,

i am facing a similar issue as zadravecm