Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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?
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
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?
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
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.
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