2 回答

TA贡献1852条经验 获得超7个赞
一个粗略的例子,但给出一个想法,将脚本文件嵌入到 html 中。理想情况下,您会使用 express 加载网页,但这纯粹是为了描述用例。
您可以对结束主体标签或结束头部标签执行相同的操作。
const http = require('http'),
const fs = require('fs');
const html = fs.readFileSync('./file.html');
const obj = fs.readFileSync('./script.js');
const htmlWithScript = html.replace(/\<\/html\s*\>/,`<script>${obj}</script></html>`);
// const htmlWithScript = `<html><head><script>${obj}</script></head><body> my html stuff ...</body></html>`
http.createServer(function(request, response) {
response.writeHeader(200, {"Content-Type": "text/html"});
response.write(htmlWithScript);
response.end();
}).listen(8000);

TA贡献1820条经验 获得超10个赞
它与UiPath-Orchestrator nodejs完美配合。
所以只需使用:
var util = require('util');
var Orchestrator = require('uipath-orchestrator');
var orchestrator = new Orchestrator({
tenancyName: 'test', // The Orchestrator Tenancy
usernameOrEmailAddress: 'xxx',// The Orchestrator login
password: 'yyy', // The Orchestrator password
hostname: 'host.company.com', // The instance hostname
isSecure: true, // optional (defaults to true)
port: 443, // optional (defaults to 80 or 443 based on isSecure)
invalidCertificate: false, // optional (defaults to false)
connectionPool: 5 // options, 0=unlimited (defaults to 1)
});
var apiPath = '/odata/Users';
var apiQuery = {};
orchestrator.get(apiPath, apiQuery, function (err, data) {
if (err) {
console.error('Error: ' + err);
}
console.log('Data: ' + util.inspect(data));
});
并将orchestrator对象提取到您的node.js代码中。
添加回答
举报