有谁能给出一个在node.js上使用o.js的例子,在提供证书的同时使用HTTPS连接?
我目前有以下直接使用node.js https
模块的示例,但我希望使用o.js
lib来避免手动创建OData URL:
const https = require("https");
const fs = require("fs");
const requestParams = {
hostname: "<the hostname>",
port: 44300,
key: fs.readFileSync("path/to/client-key.pem"),
cert: fs.readFileSync("path/to/client-crt.pem"),
ca: fs.readFileSync("path/to/ca-crt.pem"),
rejectUnauthorized : false,
path: "<the OData URL>",
method: "<GET/POST/DELETE etc>"
};
const httpsReq = https.request(requestParams, httpsRes => {
// Handle the response here
});
httpsReq.end();
1条答案
按热度按时间w6lpcovy1#
您可以像这样使用它: