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代碼中。
添加回答
舉報