Alright. I now played around. And the connection worked out with the installed node.js package.
Anyway now I need to implement it in my website.
So I struggle a bit with getting it to run in my current setup. This is how I would like to use it:
index.html:
<html>
...
<button onclick="test()">Do something</button>
...
<script src="scripts/scripts.js"></script>
...
</html>
server.js (I start with node server.js
)
var http = require('http'),
fs = require('fs');
const port = 6543;
const path = require('path');
const server = http.createServer((req, res) => {
let filePath = path.join(
__dirname,
req.url === "/" ? "index.html" : req.url
);
let extName = path.extname(filePath);
let contentType = 'text/html';
switch (extName) {
case '.js':
contentType = 'text/javascript';
break;
}
console.log(`File path: ${filePath}`);
console.log(`Content-Type: ${contentType}`);
res.writeHead(200, {'Content-Type': contentType});
const readStream = fs.createReadStream(filePath);
readStream.pipe(res);
});
server.listen(port, (err) => {
...
});
scripts.js
function test() {
...
// get the orch object here without defining it here as it contains credentials
var orchestratorInstance = new Orchestrator({
tenancyName: string (optional),
usernameOrEmailAddress: string (required),
password: string (required),
hostname: string (required),
isSecure: boolean (optional, default=true),
port: integer (optional, [1..65535], default={443,80} depending on isSecure),
invalidCertificate: boolean (optional, default=false),
connectionPool: number (optional, 0=unlimited, default=1)
});
}
This works. So the test function is fired.
But now I would like to get the Orchestrator
object (like shown here uipath-orchestrator - npm).
How to do it in the best way?
Maybe just giving that object to the scripts.js
file itself?