首页 > 解决方案 > 如何使用 nodejs 创建 https REST 客户端?

问题描述

我正在尝试使用node-rest-client从 https 端点获取数据

const Client = require('node-rest-client').Client;

const client = new Client();

client.get("https://myapi.com/data.xml", function (data, response) {
    // parsed response body as js object
    console.log(data);
    // raw response
    console.log(response);
});

但我收到了这个错误:

Error: unable to verify the first certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1049:34)
    at TLSSocket.emit (events.js:182:13)
    at TLSSocket._finishInit (_tls_wrap.js:631:8)

标签: node.jsresthttps

解决方案


推荐阅读