Search code examples
node.jsangularrestexpressxml-rpc

How to call 3rd party api like Gandi.Net from Node (server.js)


I am new to Node.Js I am creating an Mean Stack application, in which I want to call 3rd party API Gandi.Net from My Node.js code.

My Node.Js plus Express Application is getting use to make rest based API which is getting consume by my Angular client.

I found a little bit help from this link https://github.com/baalexander/node-xmlrpc. ut not so much.

Do I need to make new server for XML-RPC? If any one have did this kind of work, then any sample application will help a lot.

If any one have made any http call from node application then sample application will help.


Solution

  • It's quite easy to make an http call from the node server.
    You can use the request module.

    The documentation has tons of examples as well.

    A very simple example from the module itself

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