In node js there is an node module like http. Now include the http module into server file. By using this node module we can call webservices also.
var http = require('http');
Syntax for make http request.
try{ var Authorization = "Basic " + new Buffer("username:password").toString("base64"); var options = { host: 'IP_ADDRESS', port: PORT_NUMBER, method: 'GET', headers : { "Authorization" : Authorization } }; var reqp = http.request(options, function(resp) { resp.setEncoding('utf8'); resp.on('data', function (chunk) { // the response is in string format. So we need to convert to json. var resdata = JSON.parse(chunk); console.log(resdata); }); }); req.on('error', function(e) { console.log('problem with request: ' + e.message); }); // write data to request body reqp.write('data\n'); reqp.write('data\n'); reqp.end(); }catch(e){ console.log(e); }
You might also like:
File Upload Using Angular Js and Node Js28-05-2018 AngularJs Node js file upload multer module |
How to upload file by using request module18-03-2017 request module node js |
How to convert html to pdf in Node js12-03-2017 pdf convert html node js |
Filter for change Date format (MM-dd-yyyy) in Angular Js05-03-2017 mm-dd-yyyy date formats angular js |
How to get drop down value when drop down change using javascript27-02-2017 onchange events dropdown javascript functions |