Building on related issue: Load "Vanilla" Javascript Libraries into Node.js
I'm trying to load jQuery.soap as a NodeJS module. I have followed the steps in the linked issue but I'm having some problems calling the functions. The Soap plugins define:
return $.soap = soap;
To call the function. So I have created an index.js with this code:
var fs = require('fs');
// Read and eval library
filedata = fs.readFileSync('./node_modules/jquery.soap/jquerysoap- lib/jquery.soap.js','utf8');
eval(filedata);
exports.Soap = $.soap;
Then I'm loading it this way in my nodeJS file.
var Soap = require('jquery.soap');
and using it this way:
Soap({
url: myurl,
appendMethodToURL: false,
SOAPAction: '',
....
)};
And I'm getting a 'undefined is not a function'. Am I exporting correctly? I have tried to put
exports.Soap = soap;
instead of
exports.Soap = $.soap;
But still not working. Once I do the readFileSync should be able to call $.soap? Thanks in advance
Edit: In my VanillaJS module I have something like:
function($){
function soap (options) {
}
return $.soap = soap;
}