Is it possible to load node.js module in dojo framework used for building custom widget? Any sample code is greatly appreciated.
Can you be more specific. Also which version of JS Api are you using?
If it is about just requiring nodejs module in AMD. you can do it like below.
// This:
var fs = require("fs");
// Would become:
require([ "dojo/node!fs" ], function(fs){
// Utilise the "fs" module
});
Complete details can be found here Dojo and Node.js - Dojo Toolkit Tutorial
Hope this was helpful.
how do you incorporate the logic in widget.js?
define
([
...
'dojo/node!fs'],
function(.....,fs)
{
somefunction:function(){
fs.readFile("MyFile.json", function (err, data) {
if (err) alert("error");
});
}
});
});
I understand it is a client side script but the apps are stored in server folder once created through webappbuilder. I just need a way to manipulate the apps during runtime. I'm currently using a mixed bag with service to manipulate app on iis while the client apps on nodejs.
Hi Sapna,
I am trying to implement the same but no luck. Did you find any other way around?
I am also trying to store custom widget's run time settings into custom_config.json.
Any help would be appreciated.
Regards,
Prashant
I ended up using .net Web api rest services in my web app builder widgets.
The widget cannot load "dojo/node!fs" for me, even if i define('dojo/require'). I'm working in WAB environment. Could you give me a workaround?
Thank you!
I have the same problem to load "dojo/node!fs". I got an error message with "cannot find node.js require" . does anyone has a solution to this issue? Thanks!
Same problem here. I've tried to load SheetJS, ExcelJS, file-saver.js, and so many others, just for a simple use case of trying to export my excel document to the user.
There's ZERO documentation from Dojo on how to utilitize your node modules that you install in your widget (im using js api 3.x)