在 Node js 中向休息服务发送 https 请求的步骤 [英] Steps to send a https request to a rest service in Node js

查看:16
本文介绍了在 Node js 中向休息服务发送 https 请求的步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

节点js中的https请求发送到rest服务的步骤是什么?我有一个像 (原链接失效...)

What are the steps to send a https request in node js to a rest service? I have an api exposed like (Original link not working...)

如何传递请求以及我需要为此 API 提供哪些选项,例如主机、端口、路径和方法?

How to pass the request and what are the options I need to give for this API like host, port, path and method?

推荐答案

最简单的方法是使用 request 模块.

The easiest way is to use the request module.

request('https://example.com/url?a=b', function (error, response, body) {
  if (!error && response.statusCode == 200) {
    console.log(body);
  }
});

这篇关于在 Node js 中向休息服务发送 https 请求的步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆