Q:

Write a node.js program for making external http calls

0

Write a node.js program for making external http calls

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Solution

It is often necessary for a network application to make external HTTP calls. HTTP servers are also often called upon to perform HTTP services for clients making requests. Node.js provides an easy interface for making external HTTP calls. For example, the following code will fetch the front page of 'google.com'.

var http = require('http');
http.request({
host: 'www.google.com',
method: 'GET',
path: "/"
}, function(response) {
response.setEncoding("utf8");
response.on("readable", function() {
console.log(response.read())
});
}).end();

 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python Exercises, Practice Questions and Solutions

Similar questions


need a help?


find thousands of online teachers now
<< How to read JSON from URL requests in python?...