2017-07-03 64 views
0

我是Node.Js的新手我正在創建一個Mean Stack應用程序,我想從My Node.js中調用第三方API Gandi.Net碼。如何從Node(server.js)調用像Gandi.Net一樣的第三方api

我的Node.Js加快速應用程序正在越來越多的使用,使休息爲基礎的API,這是由我的Angular客戶端消耗。

我從這個鏈接https://github.com/baalexander/node-xmlrpc找到了一點幫助。沒有那麼多。

是否需要爲XML-RPC創建新的服務器? 如果有人做過這類工作,那麼任何示例應用程序都會有很大幫助。

如果有人從節點應用程序發起任何http調用,那麼示例應用程序將有所幫助。

回答

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. 
}); 
+0

謝謝,你有模型類,控制器和路由,任何示例應用程序? –

+0

快速搜索顯示[this](http://jasonwatmore.com/post/2015/12/09/mean-stack-user-registration-and-login-example-tutorial)示例平均堆棧應用程序。 – Shivam