如何从Node(server.js)调用Gandi.Net等第三方API

时间:2017-07-03 13:25:38

标签: node.js angular rest express xml-rpc

我是Node.Js的新手我正在创建一个Mean Stack应用程序,我想从My Node.js代码中调用第三方API Gandi.Net

My Node.Js plus Express Application正在用于制作基于休息的API,我的Angular客户端正在使用它。

我从这个链接https://github.com/baalexander/node-xmlrpc找到了一些帮助。不是那么多。

我是否需要为XML-RPC创建新服务器? 如果有人做过这种工作,那么任何样本应用程序都会有很大的帮助。

如果任何人从节点应用程序进行了任何http调用,则示例应用程序将有所帮助。

1 个答案:

答案 0 :(得分:1)

从节点服务器进行http调用非常容易 您可以使用request模块。

文档也有很多例子。

模块本身的一个非常简单的例子

var request = require('request'); 
request('http://www.google.com', 
function (error, response, body
{ 
  console.log('error:', error); // Print the error if one occurred 
  console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received 

  console.log('body:', body); // Print the HTML for the Google homepage. 
});  
相关问题