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

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

问题描述

将节点js中的https请求发送到rest服务的步骤是什么? 我有一个暴露的api,例如 https ://133-70-97-54-43.sample.com/feedSample/Query_Status_View/Query_Status/Output1?STATUS = Joined%20school

What are the steps to send a https request in node js to a rest service? I have an api exposed like https://133-70-97-54-43.sample.com/feedSample/Query_Status_View/Query_Status/Output1?STATUS=Joined%20school

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

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

推荐答案

最简单的方法是使用请求模块. /p>

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);
  }
});

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

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